<template>
  <Spin :spinning="loading" tip="Loading...">
    <div>
      <!-- table -->
      <BreakSpace label="工单及车辆信息" :containerStyle="{ marginBottom: '10px' }" />
      <FormPanel ref="formPanel1" :list="formList" :cols="4" :formType="'add'" labelWidth="100" :isSubmitBtn="false" @formChange="formChangeHandle1" />
      <BaseDialog :visible.sync="vinSelect" :title="'VIN选择'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
        <SelectVin @close="vinClose" @save="selectVinSave"></SelectVin>
      </BaseDialog>
      <BaseDialog :visible.sync="repairOrder" :title="'工单选择'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
        <SelectRepairOrder @close="repairOrderClose" @save="repairOrderSave"></SelectRepairOrder>
      </BaseDialog>
      <BaseDialog :visible.sync="mainDamagePart" :title="'主损件选择'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
        <SelectMainDamagePart @close="mainDamagePartClose" @save="mainDamagePartSave"></SelectMainDamagePart>
      </BaseDialog>
      <BaseDialog :visible.sync="faultAppear" :title="'故障现象选择'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
        <SelectFaultAppear @close="faultAppearClose" @save="faultAppearSave"></SelectFaultAppear>
      </BaseDialog>
      <BaseDialog :visible.sync="faultReason" :title="'故障原因选择'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
        <SelectFaultReason @close="faultReasonClose" @save="faultReasonSave"></SelectFaultReason>
      </BaseDialog>
      <BaseDialog :visible.sync="suppliers" :title="'供应商选择'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
        <SupplierList @close="suppliersClose" @save="suppliersSave" :rowDate="rowDate"></SupplierList>
      </BaseDialog>
      <BaseDialog :visible.sync="rescueFlag" :title="'救援单选择'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
        <SelectRescue @close="rescueClose" @save="rescueSave"></SelectRescue>
      </BaseDialog>
      <BaseDialog :visible.sync="RepairItemListaddflag" :title="'维修项目列表新增'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
        <RepairItemList @close="RepairItemListClose" @save="RepairItemListSave" :rowDate="rowDate"></RepairItemList>
      </BaseDialog>
      <BaseDialog :visible.sync="PartTakeOnlistaddflag" :title="'备件换上件列表新增'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
        <PartSelect @close="PartTakeOnClose" @save="PartTakeOnSave" :rowDate="rowDate"></PartSelect>
      </BaseDialog>
      <BaseDialog :visible.sync="PartTakeOfflistaddflag" :title="'备件换下件列表新增'" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
        <PartSelect @close="PartTakeOffClose" @save="PartTakeOffSave" ></PartSelect>
      </BaseDialog>
      <BaseDialog :visible.sync="appendItemlistaddflag" :title="'附加项目列表新增'" width="850px" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
        <appendItemlist @close="appendItemClose" @save="appendItemSave"></appendItemlist>
      </BaseDialog>
      <BaseDialog :visible.sync="batchActivities" :title="'批量活动选择'" destroyOnClose :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
        <BatchActivities @close="batchActivitiesClose" @save="batchActivitiesSave" :rowDate="rowDate"></BatchActivities>
      </BaseDialog>
      <BaseDialog :visible.sync="isvideo" :title="'视频预览'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
        <videos @close="dealercloseHandler" :src="src"/>
      </BaseDialog>
      <div style="padding-top: 1rem;"></div>
      <BreakSpace label="预授权信息" :containerStyle="{ marginBottom: '10px' }" />
      <FormPanel ref="formPanel2" :list="formList1" :cols="4" :formType="'add'" labelWidth="110" :isSubmitBtn="false" @formChange="formChangeHandle2" />
      <div style="padding-top: 1rem;"></div>
      <BreakSpace label="上传附件" :containerStyle="{ marginBottom: '10px' }" />
      <Spin :spinning="loading" tip="Loading...">
        <UploadFile  v-if="1 === 1":action-url='`${uploadPrefix}/api/file/oss/upload`':initial-value="form.fileList" :fileTypes="['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf', 'rar', 'zip','mp4','avi','rmvb','WMV','ins','inr']" :fileSize="100" :isOnlyButton="true"  :limit="10000" @change="successHandler">上传附件</UploadFile>
        <FilterTable
          ref="fileTable"
          :columns="columnsFile"
          columnsRef="whbydUploadFile"
          :isSelectColumn="false"
          :onColumnsChange="columnsFile => (this.columnsFile = columnsFile)"
          height=auto
          :dataSource="list"
        />
      </Spin>

      <!--    <BreakSpace label="外出救援" :containerStyle="{ marginBottom: '10px' }" />-->
      <!--    <FormPanel ref="formPanelRescue" :list="rescueformList" :cols="4" :formType="'add'" labelWidth="110" :isSubmitBtn="false" @formChange="formChangeHandle4" />-->

      <BreakSpace label="维修项目列表" :containerStyle="{ marginBottom: '10px' }" />
      <FilterTable
        ref="repairItemtable"
        :columns="columns"
        :params="fetchParams"
        :datakey="'items'"
        :onColumnsChange="columns => (this.columns = columns)"
        :onRowSelectChange="selectChange"
        :is-select-column="false"
        :isPagination = false
        height="auto"
      >
        <!-- 维修项目列表新增 -->
        <template slot="controls" slot-scope="props">
          <multiuse-button size="small" type="primary" icon="el-icon-plus" @click="RepairItemListadd()">添加</multiuse-button>
        </template>
      </FilterTable>
      <div style="padding-top: 1rem;"></div>
      <BreakSpace label="备件换上件列表" :containerStyle="{ marginBottom: '10px' }" />
      <FilterTable
        ref="partTakeOntable"
        :columns="columns1"
        :params="fetchParams"
        :datakey="'items'"
        :onColumnsChange="columns1 => (this.columns1 = columns1)"
        :onRowSelectChange="selectChange"
        :is-select-column="false"
        :isPagination = false
        height="auto"
      >
        <template slot="controls" slot-scope="props">
          <multiuse-button size="small" type="primary" icon="el-icon-plus" @click="PartTakeOnadd()">添加</multiuse-button>
        </template>
      </FilterTable>
      <BreakSpace label="备件换下件列表" :containerStyle="{ marginBottom: '10px' }" />
      <FilterTable
        ref="table2"
        :columns="columnspartTakeOff"
        :params="fetchParams"
        :dataSource="takeOffPartdataList"
        :datakey="'records'"
        :onColumnsChange="columnspartTakeOff => (this.columnspartTakeOff = columnspartTakeOff)"
        :onRowSelectChange="selectChange"
        :isSelectColumn = false
        :isPagination = false
        height="auto"
      >
        <template slot="controls" slot-scope="props">
          <multiuse-button size="small" type="primary" icon="el-icon-plus" @click="PartTakeOffadd()">添加</multiuse-button>
        </template>
      </FilterTable>
      <div style="padding-top: 1rem;"></div>
      <BreakSpace label="附加项目列表" :containerStyle="{ marginBottom: '10px' }" />
      <FilterTable
        ref="appendItemtable"
        :columns="columnsappendItem"
        :params="fetchParams"
        :datakey="'items'"
        :onColumnsChange="columnsappendItem => (this.columnsappendItem = columnsappendItem)"
        :onRowSelectChange="selectChange"
        :is-select-column="false"
        :isPagination = false
        height="auto"
        :onCellChange="changeCells1"
      >
        <template slot="controls" slot-scope="props">
          <multiuse-button size="small" type="primary" icon="el-icon-plus" @click="appendItemadd()">添加</multiuse-button>
        </template>
      </FilterTable>
      <div style="margin-bottom: 1rem;"></div>
      <BreakSpace label="费用信息" :containerStyle="{ marginBottom: '10px' }" />
      <FormPanel ref="formPanel3" :list="feiyongformList" :cols="4" :formType="'add'" labelWidth="110" :isSubmitBtn="false" @formChange="formChangeHandle3" />
      <div style="margin-bottom: 1rem;"></div>
      <!--    <LazyLoadTab v-model="activeName" :tabMenus="menus" :destroyOnClose="true"></LazyLoadTab>-->
      <div style="padding-top: 3rem;"></div>
      <div
        :style="{
        position: 'fixed',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
      >
        <multiuse-button @click="zuofei">作废</multiuse-button>
        <multiuse-button type="primary" :click="saveDialog.bind()">保 存</multiuse-button>
        <multiuse-button type="primary" :click="submit.bind()">提 交</multiuse-button>
        <multiuse-button @click="closeDialog">关 闭</multiuse-button>
      </div>
      <BaseDialog :title="'上传附件'" :visible.sync="upVisible" destroyOnClose>
        <uploadFile :rowData="uploadDate" @close="upVisible = false" @save="saveFile"></uploadFile>
      </BaseDialog>
    </div>
  </Spin>
</template>
<script>
import SelectRescue from './SelectRescue.vue';
import SelectVin from './SelectVin.vue';
import SelectRepairOrder from './SelectRepairOrder.vue';
import BatchActivities from '@/pages/claimDemage/tools/BatchActivities.vue';
import SelectMainDamagePart from '@/pages/claimDemage/tools/vehicle.vue';
import SelectFaultAppear from './SelectFaultAppear.vue';
import SelectFaultReason from './SelectFaultReason.vue';
import RepairItemList from './RepairItemList.vue';
import PartTakeOnlist from './PartTakeOnlist.vue';
import appendItemlist from '@/pages/claimDemage/tools/fujiaxiangmulist.vue';
import { newSave, zuofeiFun,translateByVinAndModelCode,getAuthPart,cmsClaimTypeStr } from '@/api/claim/dealer/AuthApplication';
import SupplierList from '@/pages/claimDemage/tools/SuppliersList.vue';
import PartSelect from '@/pages/claimDemage/tools/vehicleMore.vue';
import moment from 'moment';
import { dictionary } from '@/utils/dictMixin';
import { getRoLogList,getSysName1List,getSysName2List,getSysName3List,getSysName4List,getFaultName} from '@/api/claim/dealer/ClaimApplication/index';
import { isFormEmpty } from '@/utils/index';
import uploadFile from '@/pages/claimDemage/BasicData/uploadFile.vue';
import videos from './videos'
import { getSupplierList } from '@/api/dictionary';
import { getAppId } from '@/assets/js/auth';
import {getListByPage} from '@/api/claim/factory/PartAndFault';
import config from '@/assets/js/config';
export default {
  mixins: [dictionary],
  components: {
    SelectVin,
    SelectRepairOrder,
    SelectMainDamagePart,
    SelectFaultAppear,
    SelectFaultReason,
    RepairItemList,
    PartTakeOnlist,
    SelectRescue,
    appendItemlist,
    SupplierList,
    BatchActivities,
    PartSelect,
    uploadFile,
    videos
  },
  data
    () {
    return {
      uploadPrefix: config.uploadUrl,// 附件上传前缀
      uploadDate: {},
      form: {
        fileList: []
      },
      src:null,
      list: [],
      isvideo:false,
      syncList: [],
      columnsFile: this.createdTable(),
      batchActivities:false,
      loading: false,
      upVisible: false,
      rowDate: {},
      saveData: {}, //保存对象
      saveData1: null,
      saveData2: null,
      saveData3: null,
      // saveData4: null,
      saveFlag: 0,
      dataList: [],
      dataList1: [],
      fileList: [],
      selects: [],
      repairItemdataList: [],
      PartTakeOndataList: [],
      partTakeOffdataList: [],
      appendItemdataList: [],
      takeOffPartdataList:[],
      visible: false,
      visibleDrawer: false,
      appendItemCloselistaddflag: false,
      RepairItemListaddflag: false,
      PartTakeOnlistaddflag: false,
      appendItemlistaddflag: false,
      collapse: false,
      rescueFlag: false,
      vinSelect: false,
      repairOrder: false,
      faultReason: false,
      mainDamagePart: false,
      suppliers: false,
      faultAppear: false,
      infoId: null,
      flterValue: {}, //参数
      columns: this.creatHeader(),
      columns1: this.creatHeader1(),
      columnsappendItem: this.columnsappendItem1(),
      // fetchApi: getUser,
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中经销商
      hejifeiyong: 0.0,
      gongshifeiyong: 0.0,
      Partfeiyong: 0.0,
      sumfujiafeiyong: 0,
      sumfujiafeiyongz: 0,
      sumweixiufeiyongz: 0,
      partAmountsumz: 0,
      sumLabourSum: 0,
      partAmountsum: 0,
      sumPartFeiYong: 0,
      sumAmountsum: 0,
      appendItemfeiyong: 0.0,
      faId: null,
      frId: null,
      roNo: 0,
      outId: null,
      outName: null,
      selfNo: null,
      partId: null,
      modelCode: null,
      modelId: null,
      formList: this.createFormList(),
      formList1: this.createFormList1(),
      // rescueformList: this.createFormList2(),
      feiyongformList: this.feiyongformList1(),
      columnspartTakeOff: this.columnspartTakeOffFn(),
      PartTakeOfflistaddflag: false,
      // activeName: '审核记录',
      authPart: {},
      // menus: [
      //   {
      //     title: '审核记录',
      //     path: 'claimDemage/BasicData/AuthApplication/historyForAdd/checkList',
      //     params: {
      //       authId: 1
      //     }
      //   },
      //   {
      //     title: '维修历史',
      //     path: 'claimDemage/BasicData/AuthApplication/historyForAdd/repairHistory',
      //     // disabled: true,
      //     params: {
      //       vin:'%',
      //     }
      //   },
      //   {
      //     title: '索赔历史',
      //     path: 'claimDemage/BasicData/AuthApplication/historyForAdd/claimHistory',
      //     // disabled: true,
      //     params: {
      //       vin:'m%￥onkyy',
      //     }
      //   },
      //   {
      //     title: '变更记录',
      //     path: 'claimDemage/BasicData/AuthApplication/historyForAdd/changeList',
      //     // disabled: true,
      //     params: {
      //       authId: 2
      //     },
      //   },
      //   {
      //     title: '预授权历史',
      //     path: 'claimDemage/BasicData/AuthApplication/historyForAdd/preAuth',
      //     // disabled: true,
      //     params: {
      //       vin:'m%￥onkyy',
      //     }
      //   },
      // ]
    };
  },
  async created() {
    this.loading = true;
    await this.Sum();
    await this.getAuthTypeStr();
    // await this.getSupplierListStr();
    this.loading = false;
    // this.rowDate.vin='';
    //  const res3 = await getSysName1List();
    //  console.log(res3,"333333333");
    //  console.log(res3.data,"res3.datares3.datares3.data");
    //  if (res3.resultCode == 200) {
    //    this.formList1.find(x => x.fieldName == 'sysName1').initialValue = '';
    //    this.formList1.find(x => x.fieldName == 'sysName1').itemList = res3.data.map(y => ({ text: y.sysName1, value: y.sysCode1 }));
    //    //{ text: y.sysName1, value: y.faultId }
    //  }
    if(getAppId()=='arcfox'){
      this.formList1.find(x => x.fieldName == 'sysCode1').disabled = true
      this.formList1.find(x => x.fieldName == 'sysName1').disabled = true
      this.formList1.find(x => x.fieldName == 'sysCode2').disabled = true
      this.formList1.find(x => x.fieldName == 'sysName2').disabled = true
      this.formList1.find(x => x.fieldName == 'sysCode3').disabled = true
      this.formList1.find(x => x.fieldName == 'sysName3').disabled = true
      this.formList1.find(x => x.fieldName == 'sysCode4').disabled = true
      this.formList1.find(x => x.fieldName == 'sysName4').disabled = true
      this.formList1.find(x => x.fieldName == 'faultName').disabled = true
    }
  },
  mounted() {
  },
  methods: {
    dealercloseHandler(){
      this.isvideo = false;
    },
    async batchActivitiesSave(val) {
      this.formList1.find(x => x.fieldName == 'batchCode').initialValue = val[0].batchCode;
      this.formList1.find(x => x.fieldName == 'batchName').initialValue = val[0].batchName;
      let res = await getTtRpMaList({vin:this.rowDate.vin,roNo:this.rowDate.roNo,modelCode:this.rowDate.modelCode,currentPage:1,pageSize:999});
      let res1 = await queryPreClaimLog({roNo:this.rowDate.roNo});
      let data = res.data;
      let data1 = res1.data;
      if (isFormEmpty(data)) {
        data = {};
      }
      if (isFormEmpty(data1)) {
        data1 = {};
      }
      let records = data.records[0].ttRpMaLabours;
      if (isFormEmpty(records)) {
        records = [];
      }
      this.$refs.table.$refs.pageTable.EXECUTE_DELETE(this.$refs.table.$refs.pageTable.list);
      for(let i in records){
        records[i].cmsClaimPrice = records[i].labourPrice;
        records[i].cmsClaimAmount = records[i].labourSumPrice;
        records[i].labourHours = records[i].stdLabourHour;
        records[i].cmsClaimType = records[i].labourType;
        this.RepairItemListSave(records[i])
      }
      for (let i in data1.labourList) {
        this.$refs.table.$refs.pageTable.list.map(x => {
          if(x.labourCode==data1.labourList[i].labourCode){
            this.delsFun(x)
          }
        })
      }
      let arr = [];
      this.$refs.table.$refs.pageTable.list.map(x => {
        arr.push(x);
      })
      this.finalLabourList = arr;
      // let records1 = data.addList;
      // if (isFormEmpty(records1)) {
      //   records1 = [];
      // }
      // this.$refs.table3.$refs.pageTable.EXECUTE_DELETE(this.$refs.table3.$refs.pageTable.list);
      // this.appendItemSave(records1)
      // for (let i in data1.addList) {
      //   this.$refs.table3.$refs.pageTable.list.map(x => {
      //     if(x.addCode==data1.addList[i].addCode){
      //       this.delsFunFj(x)
      //     }
      //   })
      // }
      let records2 = data.records[0].ttRpMaParts;
      if (isFormEmpty(records2)) {
        records2 = [];
      }
      this.$refs.table2.$refs.pageTable.EXECUTE_DELETE(this.$refs.table2.$refs.pageTable.list);
      for(let i in records2){
        records2[i].partUnit = records2[i].unit;
        records2[i].cmsClaimPrice = records2[i].price;
        records2[i].cmsClaimAmount = records2[i].amount;
        records2[i].partCount = records2[i].counts;
        this.PartTakeOffSave(records2[i])
      }
      for (let i in data1.partList) {
        this.$refs.table2.$refs.pageTable.list.map(x => {
          if(x.partCode==data1.partList[i].partCode){
            this.$refs.table2.$refs.pageTable.EXECUTE_DELETE([x]);
          }
        })
      }
      let records3 = data.records[0].ttRpMaParts;
      if (isFormEmpty(records3)) {
        records3 = [];
      }
      this.$refs.table1.$refs.pageTable.EXECUTE_DELETE(this.$refs.table1.$refs.pageTable.list);
      for(let i in records3){
        this.PartTakeOnSave(records3[i])
      }
      for (let i in data1.partList) {
        this.$refs.table1.$refs.pageTable.list.map(x => {
          if(x.partCode==data1.partList[i].partCode){
            this.delsFunSj(x)
          }
        })
      }
      this.flag=true;
      this.batchActivities = false;
    },

    //预授权类型下拉
    async getAuthTypeStr() {

      // const res1 = await cmsClaimTypeStr({ type: 5508 });
      // if (res1.resultCode == 200) {
      //   this.formList1.find(x => x.fieldName == 'authType').itemList = res1.data.map(y => ({ text: y.codeCnDesc, value: y.codeId }));
      // }
      // const res2 = await cmsClaimTypeStr({ type: 5504 });
      // if (res2.resultCode == 200) {
      //   this.formList1.find(x => x.fieldName == 'authSub').itemList = res2.data.map(y => ({ text: y.codeCnDesc, value: y.codeId }));
      // }
    },
    async Sum() {
      console.log(this.sumfujiafeiyong);
    },
    formChangeHandle1(val) {
      console.log(val);
      this.saveData1 = val;
    },
    formChangeHandle2(val) {
      console.log(val);
      this.saveData2 = val;
    },
    formChangeHandle3(val) {
      console.log(val);
      this.saveData3 = val;
    },
    formChangeHandle4(val) {
      console.log(val);
      this.saveData4 = val;
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = val;
      console.log(val);
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    //保存
    async saveDialog() {

      if (!this.formList.find(x => x.fieldName == 'vin').initialValue) {
        return this.$notify.warning({ title: '提示信息', message: '请填写工单及车辆信息' });
      }
      this.formList.find(x => x.fieldName == 'vin').rules[0].required  = false;
      this.formList.find(x => x.fieldName == 'roNo').rules[0].required  = false;
      // this.formList.find(x => x.fieldName == 'driveMile').rules[0].required  = false;
      // this.formList.find(x => x.fieldName == 'driveMile').rules[1].pattern  = '';
      // this.formList.find(x => x.fieldName == 'deliverer').rules[0].required  = false;
      // this.formList.find(x => x.fieldName == 'delivererMobile').rules[0].required  = false;
      // this.formList.find(x => x.fieldName == 'delivererMobile').rules[1].pattern  = '';
      this.formList1.find(x => x.fieldName == 'authType').rules[0].required  = false;
      this.formList1.find(x => x.fieldName == 'authSub').rules[0].required  = false;
      this.formList1.find(x => x.fieldName == 'supName').rules[0].required  = false;

      this.formList1.find(x => x.fieldName == 'partCode').rules[0].required  = false;
      this.formList1.find(x => x.fieldName == 'faultCode').rules[0].required  = false;
      // this.formList1.find(x => x.fieldName == 'faultCode').rules[0].required  = false;

      this.formList1.find(x => x.fieldName == 'frCode').rules[0].required  = false;
      // this.formList1.find(x => x.fieldName == 'frCode').rules[0].required  = false;
      this.formList1.find(x => x.fieldName == 'faultAppear').rules[0].required  = false;
      this.formList1.find(x => x.fieldName == 'faultReason').rules[0].required  = false;

      // this.formList1.find(x => x.fieldName == 'selfNo').rules[0].required  = false;

      // this.formList1.find(x => x.fieldName == 'cmsClaimPgm').rules[0].required  = false;
      // this.formList1.find(x => x.fieldName == 'wayPicture').rules[0].required  = false;
      // this.formList1.find(x => x.fieldName == 'wayPicture1').rules[0].required  = false;
      // this.formList1.find(x => x.fieldName == 'wayPicture2').rules[0].required  = false;
      // this.formList1.find(x => x.fieldName == 'wayPicture3').rules[0].required  = false;
      // this.formList1.find(x => x.fieldName == 'sysName1').rules[0].required = false;
      // this.formList1.find(x => x.fieldName == 'sysName2').rules[0].required = false;
      // this.formList1.find(x => x.fieldName == 'sysName3').rules[0].required = false;
      // this.formList1.find(x => x.fieldName == 'sysName4').rules[0].required = false;

      this.$refs.formPanel1.SUBMIT_FORM();
      this.$refs.formPanel2.SUBMIT_FORM();
      this.$refs.formPanel3.SUBMIT_FORM();
      // this.$refs.formPanelRescue.SUBMIT_FORM();
      let arr = [];
      this.$refs.appendItemtable.$refs.pageTable.list.map(x => {
        arr.push(x);
      });
      let arr1 = [];
      this.$refs.table2.$refs.pageTable.list.map(x => {
        arr1.push(x);
      });
      console.log(arr1);

      let arr2 = [];
      this.$refs.partTakeOntable.$refs.pageTable.list.map(x => {
        arr2.push(x);
      });

      let arr3 = [];
      this.$refs.repairItemtable.$refs.pageTable.list.map(x => {
        //预授权这块关于维修类型 存数据库存的是1  因为repair那面给个一个翻译的下拉选借口写的是12345678 之后对应中文名字没有 索赔 所以暂时存上1
        // 等有了再修改这个地方目前不知道是咋回事儿呢
        x.cmsClaimType=1;
        arr3.push(x);
      });

      //维修项目
      this.saveData.labourList = arr3;
      //换上件
      this.saveData.partRList = arr2;
      //换下件
      this.saveData.partList = arr1;
      //附加项目
      this.saveData.addList = arr;

      this.saveData = Object.assign(this.saveData, this.saveData1);

      this.saveData = Object.assign(this.saveData, this.saveData2);

      this.saveData = Object.assign(this.saveData, this.saveData3);

      // this.saveData = Object.assign(this.saveData, this.saveData4);

      console.info(this.saveData);

      //判断是保存还是提交 默认0 提交1

      //追加子表的主键
      this.saveData.faId = this.faId;
      this.saveData.frId = this.frId;
      // this.saveData.outId = this.outId;
      //
      // this.saveData.outNo = this.saveData.outCode;
      // this.saveData.selfNo = this.selfNo;
      this.saveData.partId = this.partId;
      this.saveData.modelCode = this.modelCode;
      this.saveData.modelId = this.modelId;
      //销售日期
      if(this.saveData.saleDate){
        this.saveData.saleDate = moment(this.saveData.saleDate).format('YYYY-MM-DD HH:mm:ss');
      }
      //保修起始日期
      // if(this.saveData.repairBeginDate){
      //   this.saveData.repairBeginDate = moment(this.saveData.repairBeginDate).format('YYYY-MM-DD HH:mm:ss');
      // }
      //保修截止日期
      if(this.saveData.repairEndDate){
        this.saveData.repairEndDate = moment(this.saveData.repairEndDate).format('YYYY-MM-DD HH:mm:ss');
      }
      //开单时间
      if(this.saveData.roCreateDate){
        this.saveData.roCreateDate = moment(this.saveData.roCreateDate).format('YYYY-MM-DD HH:mm:ss');
      }
      // //维修开始时间
      // if(this.saveData.serviceBeginDate){
      //   this.saveData.serviceBeginDate = moment(this.saveData.serviceBeginDate).format('YYYY-MM-DD HH:mm:ss');
      // }
      // //维修结束时间
      // if(this.saveData.serviceEndDate){
      //   this.saveData.serviceEndDate = moment(this.saveData.serviceEndDate).format('YYYY-MM-DD HH:mm:ss');
      // }
      // //自费备件销售日期
      // if(this.saveData.selfSdate){
      //   this.saveData.selfSdate = moment(this.saveData.selfSdate).format('YYYY-MM-DD HH:mm:ss');
      // }
      // //生产日期
      // if(this.saveData.prodDate){
      //   this.saveData.prodDate = moment(this.saveData.prodDate).format('YYYY-MM-DD HH:mm:ss');
      // }
      if(this.saveData.supName){
        // let sup = this.selects.find(x => x.supCode == this.saveData.supName);
        this.saveData.supId = this.supId;
        this.saveData.supCode = this.supCode;
        //this.saveData.supName = sup.supName;
      }
      //   let p1 ={
      //     title :this.saveData.wayPicture[0]==undefined? null:this.saveData.wayPicture[0].name,
      //     fileUrl : this.saveData.wayPicture[0]==undefined? null:this.saveData.wayPicture[0].url,
      //     type:55041001
      //   }
      //   let p2 ={
      //     title :this.saveData.wayPicture1[0]==undefined? null:this.saveData.wayPicture1[0].name,
      //     fileUrl : this.saveData.wayPicture1[0]==undefined? null:this.saveData.wayPicture1[0].url,
      //     type:55041002
      //   }
      // let p3 ={
      //   title :this.saveData.wayPicture2[0]==undefined? null:this.saveData.wayPicture2[0].name,
      //   fileUrl : this.saveData.wayPicture2[0]==undefined? null:this.saveData.wayPicture2[0].url,
      //     type:55041003
      //   }
      //   let p4 ={
      //     title :this.saveData.wayPicture3[0]==undefined? null:this.saveData.wayPicture3[0].name,
      //     fileUrl : this.saveData.wayPicture3[0]==undefined? null:this.saveData.wayPicture3[0].url,
      //     type:55041004
      //   }
      //   let p5 ={
      //     title :this.saveData.wayPicture4[0]==undefined? null:this.saveData.wayPicture4[0].name,
      //     fileUrl : this.saveData.wayPicture4[0]==undefined? null:this.saveData.wayPicture4[0].url,
      //     type:55041005
      //   }
      //   let p6 ={
      //     title :this.saveData.wayPicture5[0]==undefined? null:this.saveData.wayPicture5[0].name,
      //     fileUrl : this.saveData.wayPicture5[0]==undefined? null:this.saveData.wayPicture5[0].url,
      //     type:55041006
      //   }
      //   this.fileList.push(p1);
      //   this.fileList.push(p2);
      //   this.fileList.push(p3);
      //   this.fileList.push(p4);
      //   this.fileList.push(p5);
      //   this.fileList.push(p6);
      this.$refs.fileTable.$refs.pageTable.list.map(x => {
        this.fileList.push(x);
      });
      this.saveData.fileList = this.fileList;
      this.saveData.authStatus=55031001;
      this.loading = true;

      let res = await newSave(this.saveData);

      if (res.resultCode === 200) {
        this.$emit('save');
        return this.$notify.success({title: '提示信息', message: '保存成功'});
      } else {
        // if (this.saveFlag === 1) {
        //   this.$notify.error({ title: '提示信息', message: res.errMsg || '提交失败!' });
        // } else {
        //   this.$notify.error({ title: '提示信息', message: res.errMsg || '保存失败!' });
        // }

        // this.closeDialog();
        this.loading = false;
      }

      this.loading = false;

    },
    changeCells1() {
      let sumsjfeiyong = 0;
      this.$refs.appendItemtable.$refs.pageTable.list.map(x => {
        sumsjfeiyong += Number(x.addAmount);
      });
      let realVal = parseFloat(sumsjfeiyong).toFixed(2);
      this.feiyongformList.map(x => {
        if ('addAmount' == x.fieldName) {
          x.initialValue = realVal;
        }
      });
      this.sumAmount();
    },
    // 上传成功回调
    successHandler(val) {
      if(val == 1){
        this.loading = true;
      }else{
        this.loading = false;
        if (val&&val.length>0) {
          if (val[0].url.errorList&&val[0].url.errorList.length>0) {
            this.errorList = val[0].url.errorList;
          }else{
            let json = JSON.parse(JSON.stringify(val));
            let data = {};
            data.createdAt = moment().format('YYYY-MM-DD HH:mm:ss');
            data.title = json[json.length - 1].name;
            data.fileUrl = json[json.length - 1].url;
            this.$refs.fileTable.$refs.pageTable.EXECUTE_INSERT(data);
          }
        }else{
          this.errorList = []
        }
      }
    },
    video(val){
      this.isvideo = true;
      this.src = val.fileUrl;
    },
    delVideo(val){
      console.log("#@!#!",val)
      this.$refs.fileTable.$refs.pageTable.EXECUTE_DELETE([val]);
    },
    //维修项目列表新增
    RepairItemListadd() {
      if(!this.formList.find(x=>x.fieldName == 'vin').initialValue){
        return this.$notify.success({title: '提示信息', message: '请先选择VIN'});
      }else{
        this.RepairItemListaddflag = true;
      }
    },
    //备件换上件列表
    PartTakeOnadd() {
      if(!this.formList.find(x=>x.fieldName == 'vin').initialValue){
        return this.$notify.success({title: '提示信息', message: '请先选择VIN'});
      }else{
        this.PartTakeOnlistaddflag = true;
      }
    },
    PartTakeOnlistadd() {
      this.PartTakeOnlistaddflag = true;
    },
    //附加项目列表
    appendItemadd() {
      this.appendItemlistaddflag = true;
    },
    //vin
    vinClose() {
      this.vinSelect = false;
    },
    //维修工单
    repairOrderClose() {
      this.repairOrder = false;
    },
    async  repairOrderSave(obj) {

      if(this.rowDate.vin){
        //如果传进来的vin跟原来的vin不相同就清空table
        if(this.rowDate.vin!== obj[0].VIN){
          let arry = this.$refs.partTakeOntable.$refs.pageTable.list;
          this.$refs.partTakeOntable.$refs.pageTable.EXECUTE_DELETE(arry);
          this.feiyongformList.map(x => {
            if ('partAmount' == x.fieldName) {
              x.initialValue = 0;
              this.partAmountsumz=0;
              this.sumAmount();
            }
          });
        }
      }
      if(this.formList1.find(item=>item.fieldName == "cmsClaimType").initialValue==55011004){
        this.formList1.find(x => x.fieldName == 'selfNo').initialValue = '';
        this.formList1.find(x => x.fieldName == 'selfSdate').initialValue = '';
        this.formList1.find(x => x.fieldName == 'selfMile').initialValue = '';
      }


      // this.menus[1].params.vin = obj[0].VIN;
      // this.menus[2].params.vin = obj[0].VIN;
      // this.menus[4].params.vin = obj[0].VIN;
      this.rowDate = obj[0];
      this.rowDate.roNo='';
      //页面上是车型名称  下面这两个是给后台传车型代码和车型id  （MODEL对应的是车型id）
      console.log(obj);
      this.modelCode = obj[0].MODEL_CODE;
      this.modelId = obj[0].MODEL;
      this.powertype = obj[0].POWER_TYPE;
      // let res = await translateByVinAndModelCode({vin:obj[0].VIN,modelCode: obj[0].MODEL_CODE,customerType: obj[0].BUSINESS_KIND});
      this.rowDate.vin= obj[0].VIN;
      let wxLog = await getRoLogList({vin:obj[0].VIN,current:1,limit:100,currentPage:1,pageNum:1,pageSize: 100,size: 100});
      if(wxLog.data.rows.length>=2){
        obj[0].lastDrive = wxLog.data.rows[wxLog.data.rows.length-2].IN_MILEAGE;
      }else{
        obj[0].lastDrive = 0
      }
      this.formList.map(x => {
        // if ('isSpecial' == x.fieldName) {
        //   x.initialValue = Number(res.data.isSpecial); //vin
        //   if(Number(res.data.isSpecial)===55321001){
        //     this.$notify.warning({ title: '提示信息', message: '该车辆为特殊车辆！' });
        //   }
        // }
        if ('vin' == x.fieldName) {
          x.initialValue = obj[0].VIN; //vin
        }
        if ('licenseNo' == x.fieldName) {
          x.initialValue = obj[0].LICENSE; //车牌号
        }
        if ('modelName' == x.fieldName) {
          x.initialValue = obj[0].MODEL_NAME; //车型名称
        }

        if ('saleDate' == x.fieldName) {
          x.initialValue = obj[0].SALES_DATE==""?null:moment(obj[0].SALES_DATE).format('YYYY-MM-DD'); //销售日期
        }

        // if ('repairBeginDate' == x.fieldName) {
        //   x.initialValue = obj[0].WRT_BEGIN_DATE==""?null:moment(obj[0].WRT_BEGIN_DATE).format('YYYY-MM-DD'); //保修起始日期
        // }

        if ('repairEndDate' == x.fieldName) {
          x.initialValue = obj[0].WRT_END_DATE==""?null:moment(obj[0].WRT_END_DATE).format('YYYY-MM-DD'); //保修起始日期
        }
        //
        // if ('serviceBeginDate' == x.fieldName) {
        //   x.initialValue = obj[0].serviceBeginDate; //维修开始时间
        // }
        // if ('serviceEndDate' == x.fieldName) {
        //   //发动机号
        //   x.initialValue = obj[0].serviceEndDate; //维修结束时间
        // }
        if ('driveMile' == x.fieldName) {
          x.initialValue = obj[0].MILEAGE; //行驶里程
        }
        if ('engineNo' == x.fieldName) {
          x.initialValue = obj[0].ENGINE_NO; //电机号
        }
        if ('customerName' == x.fieldName) {
          //车主姓名
          x.initialValue = obj[0].OWNER_NAME;
        }
        if ('customerPhone' == x.fieldName) {
          //车主手机号
          x.initialValue = obj[0].MOBILE;
        }  //提报人
        if ('applyName' == x.fieldName) {
          x.initialValue = obj[0].applyName;
        } //联系方式
        if ('applyPhone' == x.fieldName) {
          x.initialValue = obj[0].applyPhone;
        } //车辆用途
        if ('useType' == x.fieldName) {
          x.initialValue = obj[0].VEHICLE_PURPOSE;
        }
        //用户属性
        // if ('customerType' == x.fieldName) {
        //   x.initialValue =   Number(res.data.customerType);
        // }
        if ('customerType' == x.fieldName) {
          x.initialValue = obj[0].BUSINESS_KIND;
        }
        //送修人姓名
        if ('deliverer' == x.fieldName) {
          x.initialValue = obj[0].DELIVERER;
        }
        //送修人手机号
        if ('delivererMobile' == x.fieldName) {
          x.initialValue = obj[0].DELIVERER_MOBILE;
        }
        if ('lastDrive' == x.fieldName) {
          x.initialValue = obj[0].lastDrive;
        }
      });
      this.repairOrder = false;
      this.fetchParams = { ...this.fetchParams };
    },
    async  selectVinSave(obj) {
      if(this.rowDate.vin){
        //如果传进来的vin跟原来的vin不相同就清空table
        if(this.rowDate.vin!== obj[0].VIN){
          let arry = this.$refs.partTakeOntable.$refs.pageTable.list;
          this.$refs.partTakeOntable.$refs.pageTable.EXECUTE_DELETE(arry);
          this.feiyongformList.map(x => {
            if ('partAmount' == x.fieldName) {
              x.initialValue = 0;
              this.partAmountsumz=0;
              this.sumAmount();
            }
          });
        }
      }
      // this.menus[1].params.vin = obj[0].VIN;
      // this.menus[2].params.vin = obj[0].VIN;
      // this.menus[4].params.vin = obj[0].VIN;
      this.rowDate = obj[0];
      this.rowDate.roNo='';
      //页面上是车型名称  下面这两个是给后台传车型代码和车型id  （MODEL对应的是车型id）
      console.log(obj);
      this.modelCode = obj[0].MODEL_CODE;
      this.modelId = obj[0].MODEL;
      this.powertype = obj[0].POWER_TYPE;
      // let res = await translateByVinAndModelCode({vin:obj[0].VIN,modelCode: obj[0].MODEL_CODE,customerType: obj[0].BUSINESS_KIND});
      this.rowDate.vin= obj[0].VIN;
      let wxLog = await getRoLogList({vin:obj[0].VIN,current:1,limit:100,currentPage:1,pageNum:1,pageSize: 100,size: 100});
      if(wxLog.data.rows.length>=2){
        obj[0].lastDrive = wxLog.data.rows[wxLog.data.rows.length-2].IN_MILEAGE;
      }else{
        obj[0].lastDrive = 0
      }
      this.formList.map(x => {
        if ('vin' == x.fieldName) {
          x.initialValue = obj[0].VIN; //vin
        }
        if ('licenseNo' == x.fieldName) {
          x.initialValue = obj[0].LICENSE; //车牌号
        }
        if ('seriesName' == x.fieldName) {
          x.initialValue = obj[0].SERIES_NAME; //车型名称
        }
        if ('modelName' == x.fieldName) {
          x.initialValue = obj[0].MODEL_NAME; //车型名称
        }

        if ('saleDate' == x.fieldName) {
          x.initialValue = obj[0].SALES_DATE==""?null:moment(obj[0].SALES_DATE).format('YYYY-MM-DD'); //销售日期
        }

        // if ('repairBeginDate' == x.fieldName) {
        //   x.initialValue = obj[0].WRT_BEGIN_DATE==""?null:moment(obj[0].WRT_BEGIN_DATE).format('YYYY-MM-DD'); //保修起始日期
        // }

        if ('repairEndDate' == x.fieldName) {
          x.initialValue = obj[0].WRT_END_DATE==""?null:moment(obj[0].WRT_END_DATE).format('YYYY-MM-DD'); //保修起始日期
        }
        //
        // if ('serviceBeginDate' == x.fieldName) {
        //   x.initialValue = obj[0].serviceBeginDate; //维修开始时间
        // }
        // if ('serviceEndDate' == x.fieldName) {
        //   //发动机号
        //   x.initialValue = obj[0].serviceEndDate; //维修结束时间
        // }
        if ('driveMile' == x.fieldName) {
          x.initialValue = obj[0].MILEAGE; //行驶里程
        }
        if ('engineNo' == x.fieldName) {
          x.initialValue = obj[0].ENGINE_NO; //电机号
        }
        if ('customerName' == x.fieldName) {
          //车主姓名
          x.initialValue = obj[0].OWNER_NAME;
        }
        if ('customerPhone' == x.fieldName) {
          //车主手机号
          x.initialValue = obj[0].MOBILE;
        }  //提报人
        if ('applyName' == x.fieldName) {
          x.initialValue = obj[0].applyName;
        } //联系方式
        if ('applyPhone' == x.fieldName) {
          x.initialValue = obj[0].applyPhone;
        } //车辆用途
        if ('useType' == x.fieldName) {
          x.initialValue = obj[0].VEHICLE_PURPOSE;
        }
        //用户属性
        if ('customerType' == x.fieldName) {
          x.initialValue = obj[0].BUSINESS_KIND;
        }
        //送修人姓名
        if ('deliverer' == x.fieldName) {
          x.initialValue = obj[0].DELIVERER;
        }
        //送修人手机号
        if ('delivererMobile' == x.fieldName) {
          x.initialValue = obj[0].DELIVERER_MOBILE;
        }
        if ('lastDrive' == x.fieldName) {
          x.initialValue = obj[0].lastDrive;
        }
      });
      this.vinSelect = false;
      this.fetchParams = { ...this.fetchParams };

    },
    saveFile(obj){
      let list = this.$refs.appendItemtable.$refs.pageTable.list;
      list.find(x => x.addCode == obj.addCode).addFiles = obj.length==0 ? []:obj;
      this.upVisible = false;
    },
    editFile(row){
      this.upVisible = true;
      this.uploadDate = row;
    },
    //主损件
    mainDamagePartClose() {
      this.mainDamagePart = false;
    },
    async  mainDamagePartSave(obj) {
      this.partId = obj[0].partId;
      this.formList1.map(x => {
        if ('partCode' == x.fieldName) {
          x.initialValue = obj[0].partCode; //主损件返显
        }
        if ('partName' == x.fieldName) {
          x.initialValue = obj[0].partName; //主损件返显
        }
        this.changeFaultSelect();
      });
      this.rowDate.partCode = obj[0].partCode;
      this.formList1.find(x => x.fieldName == 'supName').initialValue = "";
      if( this.powertype){
        if( this.powertype  == 60081001){
          this.rowDate.ydsx = 50001001;
        }else{
          this.rowDate.ydsx = 50001002;
        }
      }
      const res  = await getSupplierList({appId : getAppId(),
        bjxmbh : this.rowDate.partCode,bjpjsx:this.rowDate.ydsx});
      if (res.resultCode == 200) {
        res.data.records.map(x => {
          x.supCode = x.bjgybm;
          x.supId = x.id;
          x.supName = x.bjgyjc;
        })
        if(res.data.records.length==1){
          this.suppliersSave(res.data.records)
        }else if(res.data.records.length==0){
          this.rowDate.partCode=""
        }

      }
      this.mainDamagePart = false;
    },
    //故障现象
    faultAppearClose() {
      this.faultAppear = false;
    },
    faultAppearSave(obj) {
      this.faId = obj[0].faultId;
      this.formList1.map(x => {
        if ('faultCode' == x.fieldName) {
          x.initialValue = obj[0].faultCode;
        }
        if ('faultName' == x.fieldName) {
          x.initialValue = obj[0].faultName; //故障现象名称返显
        }
        // if ('sysCode1' == x.fieldName) {
        //   x.initialValue = obj[0].sysCode1; //一级代码
        // }
        // if ('sysName1' == x.fieldName) {
        //   x.initialValue = obj[0].sysName1; //一级名称
        // }
        // if ('sysCode2' == x.fieldName) {
        //   x.initialValue = obj[0].sysCode2; //二级代码
        // }
        // if ('sysName2' == x.fieldName) {
        //   x.initialValue = obj[0].sysName2; //二级名称
        // }
        // if ('sysCode3' == x.fieldName) {
        //   x.initialValue = obj[0].sysCode3; //三级代码
        // }
        // if ('sysName3' == x.fieldName) {
        //   x.initialValue = obj[0].sysName3; //三级名称
        // }
        if ('sysCode4' == x.fieldName) {
          x.initialValue = obj[0].sysCode4; //代码
        }
        if ('sysName4' == x.fieldName) {
          x.initialValue = obj[0].sysName4; //名称
        }
        if ('sysCode' == x.fieldName) {
          x.initialValue = obj[0].sysCode; //故障代码
        }
        if ('faultAppera' == x.fieldName) {
          x.initialValue = obj[0].faultAppera; //故障现象
        }
      });

      this.faultAppear = false;
      this.fetchParams = { ...this.fetchParams };
    },
    //故障原因
    faultReasonClose() {
      this.faultReason = false;
    },
    faultReasonSave(obj) {
      this.frId = obj[0].frId;
      this.formList1.map(x => {
        if ('frCode' == x.fieldName) {
          x.initialValue = obj[0].frCode; //故障原因代码返显
        }
        if ('frName' == x.fieldName) {
          x.initialValue = obj[0].frName; //故障原因描述返显
        }
      });

      this.faultReason = false;
      this.fetchParams = { ...this.fetchParams };
    },
    //自费工单
    zifeigongdanClose() {
      this.zifeigongdanFlag = false;
    },
    //救援单
    rescueClose() {
      this.rescueFlag = false;
    },
    rescueSave(obj) {
      this.outId = obj[0].outId;
      // this.outName=obj[0].outName;
      // this.outNo=obj[0].outCode;
      //救援单返显
      this.formList1.map(x => {
        if ('outCode' == x.fieldName) {
          x.initialValue = obj[0].outCode; //救援号返显
        }
      });

      this.rescueFlag = false;
    },

    zifeigongdanSave(obj) {
      this.selfNo = obj[0].selfNo;
      this.formList1.map(x => {
        if ('selfNo' == x.fieldName) {
          x.initialValue = obj[0].selfNo; //主损件号返显
        }
        if ('selfSdate' == x.fieldName) {
          if(obj[0].selfSdate){
            x.initialValue = obj[0].selfSdate; //自费备件销售日期返显
          }
        }
        if ('selfMile' == x.fieldName) {
          if(obj[0].selfMile){
            x.initialValue = obj[0].selfMile; //自费备件销售里程返显
          }
        }
        // if ('selfUseHours' == x.fieldName) {
        //   if(obj[0].selfUseHours){
        //   x.initialValue = obj[0].selfUseHours; //自费备件使用时长返显
        //   }
        // }
        // if ('selfUseMile' == x.fieldName) {
        //   if(obj[0].selfUseMile){
        //   x.initialValue = obj[0].selfUseMile; //自费备件使用里程返显
        //   }
        // }

      });

      this.zifeigongdanFlag = false;
      this.fetchParams = { ...this.fetchParams };
    }, //维修项目
    RepairItemListClose() {
      this.RepairItemListaddflag = false;
    },
    RepairItemListSave(val) {
      let list = this.$refs.repairItemtable.$refs.pageTable.list;
      let values = [];
      val.map(v => {
        if(!list.find(x => x.labourCode == v.labourCode)){
          values.push(v);
        }else{
          this.$notify.error({ title: '提示信息', message: '该项目代码已添加:'+v.labourCode });
        }
      });
      for(let i =0;i<values.length;i++){
        values[i].cmsClaimType = '索赔';
        // values[i].cmsClaimAmount = 0.0;
        // values[i].labourHours = '';
      }
      this.visibleAdd = false;
      this.selectedRows = values;
      this.$refs.repairItemtable.$refs.pageTable.EXECUTE_INSERT(values);

      let sumweixiufeiyong = 0;
      this.$refs.repairItemtable.$refs.pageTable.list.map(x => {
        sumweixiufeiyong += Number(x.cmsClaimAmount);
      });
      this.feiyongformList.map(x => {
        if ('labourAmount' == x.fieldName) {
          x.initialValue = Number(sumweixiufeiyong).toFixed(2);
        }
      });
      this.sumweixiufeiyongz=sumweixiufeiyong.toFixed(2);
      this.sumAmount();

      this.RepairItemListaddflag = false;
      this.fetchParams = { ...this.fetchParams };
    },
    //备件换上件
    PartTakeOnClose() {
      this.PartTakeOnlistaddflag = false;
    },
    appendItemCloseSave() {
      this.appendItemCloselistaddflag = false;
      this.fetchParams = { ...this.fetchParams };
    },
    //附加项目
    appendItemClose() {
      this.appendItemlistaddflag = false;
    },
    appendItemSave(val) {
      let list = this.$refs.appendItemtable.$refs.pageTable.list;
      let values = [];
      val.map(v => {
        if(!list.find(x => x.addCode == v.addCode)){
          values.push(v);
        }else{
          this.$notify.error({ title: '提示信息', message: '该项目代码已添加:'+v.addCode });
        }
      });
      this.$refs.appendItemtable.$refs.pageTable.EXECUTE_INSERT(values);

      let sumfujiafeiyong = 0;
      this.$refs.appendItemtable.$refs.pageTable.list.map(x => {
        sumfujiafeiyong += Number(x.addAmount);
      });
      this.feiyongformList.map(x => {
        if ('addAmount' == x.fieldName) {
          x.initialValue = Number(sumfujiafeiyong);
        }
      });
      this.sumfujiafeiyongz=sumfujiafeiyong;
      this.sumAmount();
      this.appendItemlistaddflag = false;
      this.fetchParams = { ...this.fetchParams };
    },

    //备件换上件
    appendItemCloseClose() {
      this.appendItemCloselistaddflag = false;
    },
    async PartTakeOnSave(val) {
      this.authPart.vin = this.rowDate.vin;
      this.authPart.modelCode = this.modelCode;
      this.authPart.partList = val;
      let res = await getAuthPart(this.authPart);
      let list = this.$refs.partTakeOntable.$refs.pageTable.list;
      let values = [];
      res.data.map(v => {
        if(!list.find(x => x.partCode == v.partCode)){
          v.partCount=1;
          v.cmsClaimAmount =  parseFloat(v.partCount * Number(v.cmsClaimPrice)).toFixed(2);
          values.push(v);
        }else{
          this.$notify.error({ title: '提示信息', message: '该备件代码已添加:'+v.partCode });
        }
      });
      // for(let i =0;i<values.length;i++){
      //   values[i].partCount ='';
      //   values[i].cmsClaimAmount = 0.0;
      // }
      this.PartTakeOnlistaddflag = false;
      this.$refs.partTakeOntable.$refs.pageTable.EXECUTE_INSERT(values);

      let partAmountsum = 0;
      this.$refs.partTakeOntable.$refs.pageTable.list.map(x => {
        this.sumAmountsum += Number(x.cmsClaimAmount);
        partAmountsum += Number(x.cmsClaimAmount);
      });
      this.feiyongformList.map(x => {
        if ('partAmount' == x.fieldName) {
          x.initialValue = partAmountsum.toFixed(2);
        }
      });
      this.partAmountsumz=partAmountsum.toFixed(2);
      this.sumAmount();

      this.PartTakeOnlistaddflag = false;
    },
    suppliersClose(){
      this.suppliers = false;
    },
    batchActivitiesClose() {
      this.batchActivities = false;
    },
    suppliersSave(obj) {
      this.formList1.find(x => x.fieldName == 'supName').initialValue = obj[0].supName;
      this.supCode = obj[0].supCode;
      this.supId = obj[0].supId;
      this.suppliers = false;
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
    },
    chooseOrderNo() {
      this.visible = true;
    }, //维修工单号选择
    selectVin() {
      this.vinSelect = true;
    },
    selectRono() {
      this.repairOrder = true;
    },
    selectpartCode() {
      this.mainDamagePart = true;
    },
    selectSuppliersCode() {
      this.suppliers = true;
    },
    selectfaultCode() {
      this.faultAppear = true;
    },
    selectfaultReason() {
      this.faultReason = true;
    },
    selectselfNo() {
      if(this.rowDate.vin){
        this.zifeigongdanFlag = true;
      } else {
        this.$notify.error({ title: '提示信息', message: '请选择VIN' });
      }
    },
    selectoutNo() {
      this.rescueFlag = true;
    },
    add() {},
    sumAmount() {
      let sum = 0;
      this.$refs.appendItemtable.$refs.pageTable.list.map(x => {
        sum += Number(x.addAmount);
      });

      this.$refs.repairItemtable.$refs.pageTable.list.map(x => {
        sum += Number(x.cmsClaimAmount);
      });

      this.$refs.partTakeOntable.$refs.pageTable.list.map(x => {
        sum += Number(x.cmsClaimAmount);
      });
      this.feiyongformList.map(x => {
        if('sumAmount' == x.fieldName) {
          x.initialValue = sum.toFixed(2);
        }
      });

    },
    // selfCode(val){
    //   this.formList1.map(y => {
    //     if (y.fieldName == 'selfNo') {
    //       y.hidden = true;
    //       y.initialValue = undefined;
    //     }
    //     if (y.fieldName == 'selfSdate') {
    //       y.hidden = true;
    //       y.initialValue = undefined;
    //     }
    //     if (y.fieldName == 'selfMile') {
    //       y.hidden = true;
    //       y.initialValue = undefined;
    //     }
    //     if (y.fieldName == 'cmsClaimType') {
    //       y.initialValue = val;
    //     }
    //     if (y.fieldName == 'maNo') {
    //       y.disabled = true;
    //     }
    //   })
    // },
    //备件换下件列表
    PartTakeOffadd() {
      this.PartTakeOfflistaddflag = true;
    },
    //备件换下件
    PartTakeOffClose() {
      this.PartTakeOfflistaddflag = false;
    },
    PartTakeOffSave(val) {
      let values = [];
      val.map(v => {
        if(!this.$refs.table2.$refs.pageTable.list.find(x => x.partCode == v.partCode)){
          v.partCount=1;
          values.push(v);
        }else{
          this.$notify.error({ title: '提示信息', message: '该备件代码已添加:'+v.partCode });
        }
      });
      this.$refs.table2.$refs.pageTable.EXECUTE_INSERT(values);
      // }
      this.PartTakeOfflistaddflag = false;
    },
    delsFunXj(data) {
      this.$refs.table2.$refs.pageTable.EXECUTE_DELETE([data]);
    },
    chuanvalue(data) {
      console.log(data,"救救我aaa");
      this.formList1.map(x => {
        if ('partCode' == x.fieldName) {
          x.initialValue = data.partCode; //主损件返显
        }
        if ('partName' == x.fieldName) {
          x.initialValue = data.partName; //主损件返显
        }
      });
      this.changeFaultSelect();

    },
    createFormList() {
      return [
        // {
        //   type: 'INPUT',
        //   label: '预授权单号',
        //   fieldName: 'authNo',
        //   placeholder: '请输入预授权单号...',
        //   disabled: true
        // },
        {
          type: 'INPUT',
          label: 'VIN',
          fieldName: 'vin',
          initialValue: '',
          readonly: true,
          placeholder: '请输入VIN...',
          rules: [{ required: true, message: '请输入VIN...', trigger: 'blur' }],
          unitRender: p => {
            return (
              <div>
                <multiuse-button icon="el-icon-search" onClick={() => this.selectVin()} />
              </div>
            );
          }
        },
        {
          type: 'INPUT',
          label: '车牌号',
          fieldName: 'licenseNo',
          disabled: true,
          placeholder: '请输入车牌号...'
        },
        {
          type: 'INPUT',
          label: '维修工单号',
          fieldName: 'roNo',
          initialValue: '',
          readonly: true,
          placeholder: '请输入维修工单号...',
          rules: [{ required: false, message: '请填维修工单号', trigger: 'blur' }],
          unitRender: p => {
            return (
              <div>
                <multiuse-button icon="el-icon-search" onClick={() => this.selectRono()} />
              </div>
            );
          }
        },
        // {
        //   type: 'SELECT',
        //   label: '预授权状态',
        //   fieldName: 'authStatus',
        //   disabled: true,
        //   itemList:[],
        //   placeholder: '请输入标题名称...'
        // },
        // {
        //   type: 'INPUT',
        //   label: 'VIN',
        //   fieldName: 'vin',
        //   disabled: true,
        //   placeholder: '请输入标题名称...'
        // },
        // RO_CREATE_DATE
        {
          type: 'INPUT',
          label: '开单日期',
          fieldName: 'roCreateDate',
          placeholder: '请输入开单日期...',
          readonly: true, // 只读
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '车系名称',
          fieldName: 'seriesName',
          disabled: true,
          placeholder: '请输入车系名称...'
        },
        {
          type: 'INPUT',
          label: '车型名称',
          fieldName: 'modelName',
          disabled: true,
          placeholder: '请输入车型名称...'
        },
        {
          type: 'INPUT',
          label: '销售日期',
          fieldName: 'saleDate',
          placeholder: '请输入销售日期...',
          readonly: true, // 只读
          disabled: true,
        },
        // {
        //   type: 'INPUT',
        //   label: '保修起始日期',
        //   fieldName: 'repairBeginDate',
        //   placeholder: '请输入保修起始日期...',
        //   readonly: true, // 只读
        //   disabled: true,
        // },
        {
          type: 'INPUT',
          label: '保修截止日期',
          fieldName: 'repairEndDate',
          disabled: true,
          placeholder: '请输入保修截止日期...'
        },
        // {
        //   type: 'DATE',
        //   label: '维修开始时间',
        //   fieldName: 'serviceBeginDate',
        //   placeholder: '请输入标题名称...',
        //   valueFormat:'yyyy-MM-DD HH:mm:ss',
        //   readonly: true, // 只读
        //   disabled: true,
        // },
        // {
        //   type: 'DATE',
        //   label: '维修结束时间',
        //   fieldName: 'serviceEndDate',
        //   placeholder: '请输入标题名称...',
        //   valueFormat:'yyyy-MM-DD HH:mm:ss',
        //   readonly: true, // 只读
        //   disabled: true,
        // },
        {
          type: 'SELECT',
          label: '用户属性',
          fieldName: 'customerType',
          disabled: true,
          initialValue: undefined,
          itemList: this.createDictList('4103')
        },
        {
          type: 'INPUT',
          label: '车辆用途',
          style: { minWidth: '200px' },
          disabled: true,
          fieldName: 'useType',
        },
        {
          type: 'INPUT',
          label: '行驶里程',
          disabled: true,
          unitRender: () => {
            return <span>(KM)</span>;
          },
          rules: [{ required: false, message: '请输入行驶里程...', trigger: 'blur' }, { pattern: /[\d\.]+/g, message: '请输入数字...', trigger: 'blur' }],
          fieldName: 'driveMile',
          placeholder: '请输入行驶里程...',
          change:  val => {
            if(Number(val)<Number(this.formList.find(x => x.fieldName == 'lastDrive').initialValue)){
              this.formList.find(x => x.fieldName == 'driveMile').initialValue =null;
              return this.$notify.success({title: '提示信息', message: '里程数小于上次行驶里程'});
            }
          }
        },
        {
          type: 'INPUT',
          label: '电机号',
          fieldName: 'engineNo',
          disabled: true,
          placeholder: '请输入电机号...'
        },
        // {
        //   type: 'INPUT',
        //   label: '生产日期',
        //   fieldName: 'prodDate',
        //   disabled: true,
        //   placeholder: '请输入生产日期...'
        // },


        // {
        //   type: 'SELECT',
        //   label: '是否特殊车辆',
        //   fieldName: 'isSpecial',
        //   disabled: true,
        //   initialValue: undefined,
        //   itemList: this.createDictList('5532')
        // },
        {
          type: 'INPUT',
          label: '车主姓名',
          fieldName: 'customerName',
          disabled: true,
          placeholder: '请输入车主姓名...'
        },
        {
          type: 'INPUT',
          label: '车主手机号',
          fieldName: 'customerPhone',
          disabled: true,
          placeholder: '请输入车主手机号...'
        },

        //
        // {
        //   type: 'INPUT',
        //   label: '上次维修里程',
        //   fieldName: 'lastDrive',
        //   disabled: true,
        //   initialValue: '',
        //   unitRender: () => {
        //     return <span>(KM)</span>;
        //   },
        // },

        {
          type: 'INPUT',
          label: '送修人姓名',
          fieldName: 'deliverer',
          disabled: true,
          // rules: [{ required: false, message: '请输入送修人姓名...', trigger: 'blur' }],
          placeholder: '请输入送修人姓名...'
        },
        {
          type: 'INPUT',
          label: '送修人手机号',
          fieldName: 'delivererMobile',
          disabled: true,
          // rules: [{ required: false, message: '请输入送修人手机号...', trigger: 'blur' },{pattern:/^[1][3,4,5,6,7,8,9][0-9]{9}$/,message:'请填写正确的手机号格式...',trigger: 'blur'}],
          placeholder: '请输入送修人手机号...'
        },
        {
          type: 'INPUT',
          label: '提报人',
          fieldName: 'serviceName',
          placeholder: '提报人',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '联系方式',
          fieldName: 'servicePhone',
          placeholder: '联系方式',
          disabled: false
        },
        {
          type: 'INPUT',
          label: '电池编号',
          fieldName: 'batteryNo',
          rules: [{ required: false, message: '请输入电池编号...', trigger: 'blur' }],
          placeholder: '请输入电池编号...'
        },
      ];
    },
    async changeFaultSelect() {
      if(getAppId()=='beijing'){
        console.log("一点");
        let partCode = await getListByPage({appId: getAppId(),faStatus:1,partCode: this.formList1.find(x => x.fieldName == 'partCode').initialValue,current:1,currentPage:1,limit:20,pageNum:1,pageSize:20,size:20});
        console.log(partCode.data.records,"两点");
        if (partCode.data.records.length <= 0) {
          this.formList1.find(x => x.fieldName == 'sysCode1').initialValue = '';
          this.formList1.find(x => x.fieldName == 'sysName1').initialValue = '';
          this.formList1.find(x => x.fieldName == 'sysCode2').initialValue = '';
          this.formList1.find(x => x.fieldName == 'sysName2').initialValue = '';
          this.formList1.find(x => x.fieldName == 'sysCode3').initialValue = '';
          this.formList1.find(x => x.fieldName == 'sysName3').initialValue = '';
          this.formList1.find(x => x.fieldName == 'sysCode4').initialValue = '';
          this.formList1.find(x => x.fieldName == 'sysName4').initialValue = '';
          this.formList1.find(x => x.fieldName == 'faultCode').initialValue = '';
          this.formList1.find(x => x.fieldName == 'faultName').initialValue = '';
        }else{
          this.formList1.find(x => x.fieldName == 'sysCode1').initialValue = partCode.data.records[0].sysCode1;
          this.formList1.find(x => x.fieldName == 'sysName1').initialValue = partCode.data.records[0].sysName1;
          this.formList1.find(x => x.fieldName == 'sysCode2').initialValue = partCode.data.records[0].sysCode2;
          this.formList1.find(x => x.fieldName == 'sysName2').initialValue = partCode.data.records[0].sysName2;
          this.formList1.find(x => x.fieldName == 'sysCode3').initialValue = partCode.data.records[0].sysCode3;
          this.formList1.find(x => x.fieldName == 'sysName3').initialValue = partCode.data.records[0].sysName3;
          this.formList1.find(x => x.fieldName == 'sysCode4').initialValue = partCode.data.records[0].sysCode4;
          this.formList1.find(x => x.fieldName == 'sysName4').initialValue = partCode.data.records[0].sysName4;
          this.formList1.find(x => x.fieldName == 'faultCode').initialValue = partCode.data.records[0].faultCode;
          this.formList1.find(x => x.fieldName == 'faultName').initialValue = partCode.data.records[0].faultName;
          this.faId = partCode.data.records[0].faultId;
        }
      }
    },

    // async changeSysName1Select(sysCode1) {
    //   console.log(sysCode1,"sysCode1sysCode1sysCode1");
    //   this.formList1.find(item=>item.fieldName==='sysName2').initialValue = '';
    //   this.formList1.find(item=>item.fieldName==='sysCode2').initialValue = '';
    //   this.formList1.find(item=>item.fieldName==='sysName2').itemList = [];
    //   this.formList1.find(item=>item.fieldName==='sysName3').initialValue = '';
    //   this.formList1.find(item=>item.fieldName==='sysCode3').initialValue = '';
    //   this.formList1.find(item=>item.fieldName==='sysName3').itemList = [];
    //   this.formList1.find(item=>item.fieldName==='sysName4').initialValue = '';
    //   this.formList1.find(item=>item.fieldName==='sysCode4').initialValue = '';
    //   this.formList1.find(item=>item.fieldName==='sysName4').itemList = [];
    //   if (sysCode1) {
    //     const res = await getSysName2List(sysCode1);
    //     if (res.resultCode === 200) {
    //       console.log(res,"resresresresresresresresresresresresresresres");
    //       console.log(res.data,"res.datares.datares.datares.datares.datares.datares.data");
    //       this.formList1.find(item=>item.fieldName==='sysName2').itemList = res.data.map(x => ({ text: x.sysName2,value:x.sysCode2 }));
    //     }
    //   }
    // },

    // async changeSysName2Select(sysCode2) {
    //   const sysCode1 = this.formList1.find(item=>item.fieldName==='sysCode1').initialValue;
    //   console.log(sysCode1,"sysCode1sysCode1sysCode1sysCode1sysCode1sysCode1sysCode1sysCode1sysCode1");
    //   if (sysCode1 && sysCode2) {
    //     this.formList1.find(item=>item.fieldName==='sysName3').initialValue = '';
    //     this.formList1.find(item=>item.fieldName==='sysCode3').initialValue = '';
    //     this.formList1.find(item=>item.fieldName==='sysName3').itemList = [];
    //     this.formList1.find(item=>item.fieldName==='sysName4').initialValue = '';
    //     this.formList1.find(item=>item.fieldName==='sysCode4').initialValue = '';
    //     this.formList1.find(item=>item.fieldName==='sysName4').itemList = [];
    //     const res = await getSysName3List(sysCode1,sysCode2);
    //     if (res.resultCode === 200) {
    //       console.log(res,"resresresresresresresresresresresresresresres");
    //       console.log(res.data,"res.datares.datares.datares.datares.datares.datares.data");
    //     this.formList1.find(item=>item.fieldName==='sysName3').itemList = res.data.map(x => ({ text: x.sysName3,value:x.sysCode3 }));
    //     }
    //   }
    // },
    // async changeSysName3Select(sysCode3) {
    //   const sysCode1 = this.formList1.find(item=>item.fieldName==='sysCode1').initialValue;
    //   const sysCode2 = this.formList1.find(item=>item.fieldName==='sysCode2').initialValue;
    //   console.log(sysCode3,"sysCode3sysCode3sysCode3sysCode3sysCode3");
    //   if (sysCode1 && sysCode2 &&sysCode3) {
    //     this.formList1.find(item=>item.fieldName==='sysName4').initialValue = '';
    //     this.formList1.find(item=>item.fieldName==='sysCode4').initialValue = '';
    //     this.formList1.find(item=>item.fieldName==='sysName4').itemList = [];
    //     const res = await getSysName4List(sysCode1,sysCode2,sysCode3);
    //     if (res.resultCode === 200) {
    //       console.log(res,"mmmmmmmm");
    //       console.log(res.data,"sysName4sysName4sysName4sysName4sysName4");
    //     this.formList1.find(item=>item.fieldName==='sysName4').itemList = res.data.map(x => ({ text: x.sysName4,value:x.sysCode4 }));
    //     }
    //   }
    //
    // },

    async getFaultNameSelect(sysCode4){
      const sysCode1 = this.formList1.find(item=>item.fieldName==='sysCode1').initialValue;
      const sysCode2 = this.formList1.find(item=>item.fieldName==='sysCode2').initialValue;
      const sysCode3 = this.formList1.find(item=>item.fieldName==='sysCode3').initialValue;
      if (sysCode1 && sysCode2 &&sysCode3 && sysCode4) {
        const res = await getFaultName(sysCode1,sysCode2,sysCode3,sysCode4);
        if (res.resultCode === 200) {
          console.log(res,"lllllllluuuu");
          console.log(res.data,"FaultNameFaultNameFaultNameFaultName");
          this.formList1.find(x => x.fieldName == 'faultName').initialValue = res.data[0].faultName;
          this.formList1.find(x => x.fieldName == 'faultCode').initialValue = res.data[0].faultCode;
          this.faId = res.data[0].faultId;
          console.log(res,"成功了嘛");
        }
      }
    },
    selfCode(val){
      this.formList1.map(y => {
        if (y.fieldName == 'authSub') {
          y.hidden = true;
          y.initialValue = undefined;
        }
        // this.formList1.map(y => {
        //   if (y.fieldName == 'responsiblePerson') {
        //     y.hidden = true;
        //     y.initialValue = undefined;
        //   }
        // })
        // this.formList1.map(y => {
        //   if (y.fieldName == 'payReason') {
        //     y.hidden = true;
        //     y.initialValue = undefined;
        //   }
        // })
        this.formList.map(y => {
          if (y.fieldName == 'roNo') {
            y.rules[0].required = false;
          }
        })
        if (y.fieldName == 'authType') {
          y.initialValue = val;
        }
      })
    },
    createFormList1() {
      return [
        { type: 'SELECT', label: '预授权类型', fieldName: 'authType', placeholder: '请选择预授权类型...', initialValue: '', itemList:this.createDictList('5508',[]), filterable: true,
          rules: [{ required: true, message: '请选择预授权类型...', trigger: 'blur' }],
          change: val => {
            if (val == 55081003) {
              this.formList1.map(y => {
                if (y.fieldName == 'authSub') {
                  y.hidden = false;
                }
                // if (y.fieldName == 'payReason') {
                //   y.hidden = true;
                //   y.initialValue = undefined;
                // }
                // if (y.fieldName == 'responsiblePerson') {
                //   y.hidden = true;
                //   y.initialValue = undefined;
                // }
                if (y.fieldName == 'authType') {
                  y.initialValue = val;
                }
              })
              this.formList.map(y => {
                if (y.fieldName == 'roNo') {
                  y.rules[0].required = false;
                }
              })

            } else if(val == 55081004){
              this.formList1.map(y => {
                if (y.fieldName == 'authSub') {
                  y.hidden = true;
                  y.initialValue = undefined;
                }
                // if (y.fieldName == 'responsiblePerson') {
                //   y.hidden = false;
                // }
                // if (y.fieldName == 'payReason') {
                //   y.hidden = false;
                // }
                if (y.fieldName == 'authType') {
                  y.initialValue = val;
                }
              })
              this.formList.map(y => {
                if (y.fieldName == 'roNo') {
                  y.rules[0].required = false;
                }
              })

            } else if(val == 55081002){
              this.formList1.map(y => {
                if (y.fieldName == 'authSub') {
                  y.hidden = true;
                  y.initialValue = undefined;
                }
                // if (y.fieldName == 'responsiblePerson') {
                //   y.hidden = true;
                //   y.initialValue = undefined;
                // }
                // if (y.fieldName == 'payReason') {
                //   y.hidden = true;
                //   y.initialValue = undefined;
                // }
                if (y.fieldName == 'authType') {
                  y.initialValue = val;
                }
              })
              this.formList.map(y => {
                if (y.fieldName == 'roNo') {
                  y.rules[0].required = true;
                }
              })
            }else {
              this.selfCode(val);
            }
          }
        },

        { type: 'SELECT', label: '常规预授权分类', fieldName: 'authSub',
          placeholder: '请选择常规预授权分类...',
          hidden: true,
          filterable: true,
          itemList:this.createDictList('5504',[]),
          rules: [{ required: true, message: '请选择常规预授权分类...', trigger: 'blur' }],
        },
        {
          type: 'INPUT',
          label: '主损件',
          fieldName: 'partCode',
          readonly: true,
          //disabled: true,
          placeholder: '请选择主损件...',
          rules: [{ required: true, message: '请选择主损件...', trigger: 'blur' }],
          unitRender: p => {
            return (
              <div>
                <multiuse-button icon="el-icon-search" onClick={() => this.selectpartCode()} />
              </div>
            );
          }
        },
        {
          type: 'INPUT',
          label: '主损件名称',
          fieldName: 'partName',
          disabled: true,
          placeholder: '请输入主损件名称...'
        },
        { type: 'INPUT',
          label: '供应商',
          fieldName: 'supName',
          placeholder: '请选择供应商...',
          readonly: true,
          rules: [{ required: true, message: '请输入供应商', trigger: 'blur' }],
          unitRender: p => {
            return (
              <div>
                <multiuse-button icon="el-icon-search" onClick={() => this.selectSuppliersCode()} />
              </div>
            );
          }
        },
        { type: 'INPUT',
          label: '责任商',
          fieldName: 'responsiblePerson',
          // hidden: true,
          placeholder: '请输入责任商...',
          rules: [{ required: true, message: '请输入责任商', trigger: 'blur' }]
        },
        { type: 'INPUT',
          label: '赔付原因',
          fieldName: 'payReason',
          // hidden: true,
          placeholder: '请输入赔付原因...',
          rules: [{ required: true, message: '请输入赔付原因', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '故障现象',
          fieldName: 'sysName4',
          readonly: true,
          placeholder: '请选择故障现象...',
          rules: [{ required: true, message: '请选择故障现象...', trigger: 'blur' }],
          unitRender: p => {
            return (
              <div>
                <multiuse-button icon="el-icon-search" onClick={() => this.selectfaultCode()} />
              </div>
            );
          }
        },
        // {
        //   type: 'INPUT',
        //   label: '故障现象描述',
        //   fieldName: 'faultName',
        //   disabled: true,
        //   placeholder: '请输入...'
        // },
        //   {
        //     type: 'INPUT',
        //     label: '一级代码',
        //     fieldName: 'sysCode1',
        //     disabled: true,
        //     placeholder: '请输入...'
        //   },
        //
        // {
        //   type: 'SELECT',
        //   label: '一级名称',
        //   fieldName: 'sysName1',
        //   placeholder: '请选择...',
        //   disabled: false,
        //   itemList: [],
        //   rules: [{required: true, message: '请选择一级名称...', trigger: 'change'}],
        //   change: val => {
        //       this.changeSysName1Select(val);
        //       let sysName1 = this.formList1.find(x => x.fieldName == 'sysCode1').initialValue
        //       let list = this.formList1.find(x => x.fieldName === 'sysName1').itemList;
        //       console.log(val,"ybbb");
        //       this.formList1.find(x => x.fieldName == 'sysCode1').initialValue =list.find(x => x.value === val).value;
        //       console.log("sppp");
        //   }
        // },
        //   {
        //     type: 'INPUT',
        //     label: '二级代码',
        //     fieldName: 'sysCode2',
        //     disabled: true,
        //     placeholder: '请输入...'
        //   },
        //
        // {
        //   type: 'SELECT',
        //   label: '二级名称',
        //   fieldName: 'sysName2',
        //   placeholder: '请选择...',
        //   disabled: false,
        //   itemList: [],
        //   rules: [{required: true, message: '请选择二级名称...', trigger: 'change'}],
        //   change: val => {
        //       let list1 = this.formList1.find(x => x.fieldName === 'sysName2').itemList;
        //       this.formList1.find(x => x.fieldName == 'sysCode2').initialValue =list1.find(x => x.value === val).value;
        //       this.changeSysName2Select(val);
        //   }
        // },
        //   {
        //     type: 'INPUT',
        //     label: '三级代码',
        //     fieldName: 'sysCode3',
        //     disabled: true,
        //     placeholder: '请输入...'
        //   },
        //
        // {
        //   type: 'SELECT',
        //   label: '三级名称',
        //   fieldName: 'sysName3',
        //   placeholder: '请输入...',
        //   disabled: false,
        //   itemList: [],
        //   rules: [{required: true, message: '请选择三级名称...', trigger: 'change'}],
        //   change: val => {
        //       let list2 = this.formList1.find(x => x.fieldName === 'sysName3').itemList;
        //       this.formList1.find(x => x.fieldName == 'sysCode3').initialValue =list2.find(x => x.value === val).value;
        //       this.changeSysName3Select(val);
        //   }
        // },

        //   {
        //     type: 'INPUT',
        //     label: '故障现象',
        //     fieldName: 'sysCode4',
        //     disabled: true,
        //     placeholder: '请输入...'
        //   },
        // {
        //   type: 'SELECT',
        //   label: '故障描述',
        //   fieldName: 'sysName4',
        //   placeholder: '请输入...',
        //   disabled: false,
        //   itemList: [],
        //   rules: [{required: true, message: '请选择故障描述...', trigger: 'change'}],
        //   change: val => {
        //       let list3 = this.formList1.find(x => x.fieldName === 'sysName4').itemList;
        //       this.formList1.find(x => x.fieldName == 'sysCode4').initialValue =list3.find(x => x.value === val).value;
        //       this.getFaultNameSelect(val);
        //   }
        // },
        {
          type: 'INPUT',
          label: '故障原因',
          fieldName: 'frName',
          readonly: true,
          placeholder: '请选择故障原因...',
          rules: [{ required: true, message: '请选择故障原因...', trigger: 'blur' }],
          unitRender: p => {
            return (
              <div>
                <multiuse-button icon="el-icon-search" onClick={() => this.selectfaultReason()} />
              </div>
            );
          }
        },
        // {
        //   type: 'INPUT',
        //   label: '原因代码名称',
        //   disabled: true,
        //   fieldName: 'frName',
        //   placeholder: '请输入...'
        // },

        // {
        //   type: 'INPUT',
        //   label: '外出救援单号',
        //   // fieldName: 'outNo',
        //   fieldName: 'outCode',
        //   readonly: true,
        //   placeholder: '请输入救援单号...',
        //   unitRender: p => {
        //     return (
        //       <div>
        //       <multiuse-button icon="el-icon-search" onClick={() => this.selectoutNo()} />
        //     </div>
        //   );
        //   }
        // },
        // {
        //   type: 'INPUT',
        //   label: '自费工单选择',
        //   fieldName: 'selfNo',
        //   hidden: true,
        //   readonly: true,
        //   placeholder: '请输入...',
        //   rules: [{ required: true, message: '请选择自费工单', trigger: 'blur' }],
        //   unitRender: p => {
        //     return (
        //       <div>
        //       <multiuse-button icon="el-icon-search" onClick={() => this.selectselfNo()} />
        //     </div>
        //   );
        //   }
        // },
        // {
        //   type: 'DATE',
        //   label: '自费备件销售日期',
        //   fieldName: 'selfSdate',
        //   disabled: true,
        //   hidden: true,
        //   valueFormat:'yyyy-MM-DD',
        //   placeholder: '请输入...'
        // },
        // {
        //   type: 'INPUT',
        //   label: '自费备件销售里程',
        //   fieldName: 'selfMile',
        //   disabled: true,
        //   hidden: true,
        //   placeholder: '请输入...'
        // },
        // {
        //   type: 'INPUT',
        //   label: '自费备件使用时长',
        //   disabled: true,
        //   hidden: true,
        //   fieldName: 'selfUseHours',
        //   placeholder: '请输入...'
        // },
        // {
        //   type: 'INPUT',
        //   label: '自费备件使用里程',
        //   disabled: true,
        //   hidden: true,
        //   fieldName: 'selfUseMile',
        //   placeholder: '请输入...'
        // },
        {
          type: 'TEXT_AREA',
          label: '故障现象描述',
          fieldName: 'faultAppear',
          rules: [{ required: true, message: '请输入故障现象...', trigger: 'blur' }],
          placeholder: '请输入故障现象...',
          rows: 3,
          selfCols: 4 // 元素占据几行
        },
        {
          type: 'TEXT_AREA',
          label: '故障原因描述',
          fieldName: 'faultReason',
          rules: [{ required: true, message: '请输入故障原因...', trigger: 'blur' }],
          placeholder: '请输入故障原因...',
          rows: 3,
          selfCols: 4 // 元素占据几行
        },
        {
          type: 'TEXT_AREA',
          label: '维修方案描述',
          fieldName: 'cmsClaimPgm',
          rules: [{ required: true, message: '请输入维修方案...', trigger: 'blur' }],
          placeholder: '请输入维修方案...',
          rows: 3,
          selfCols: 4 // 元素占据几行
        },
        // {
        //   type: 'BREAK_SPACE',
        //   label: '附件'
        // },
        // {
        //   type: 'UPLOAD_IMG',
        //   label: 'VIN（B柱/前风挡）',
        //   fieldName: 'wayPicture',
        //   placeholder: '上传VIN（B柱/前风挡）...',
        //   selfCols: 1,
        //   initialValue: [],
        //   rules: [{ required: true, message: '请上传VIN（B柱/前风挡）', trigger: 'change' }],
        //   upload: {
        //     actionUrl: '/api/file/oss/upload',
        //     fixedSize: [5, 3],
        //     limit: 1,
        //     isCalcHeight: true,
        //     isFileName:true,
        //   }
        // },
        // {
        //   type: 'UPLOAD_IMG',
        //   label: '里程（仪表）',
        //   fieldName: 'wayPicture1',
        //   placeholder: '上传里程（仪表）...',
        //   selfCols: 1,
        //   initialValue: [],
        //   rules: [{ required: true, message: '请上传里程（仪表）', trigger: 'change' }],
        //   upload: {
        //     actionUrl: '/api/file/oss/upload',
        //     fixedSize: [5, 3],
        //     limit: 1,
        //     isCalcHeight: true,
        //     isFileName:true,
        //   }
        // },
        // {
        //   type: 'UPLOAD_IMG',
        //   label: '车牌（车头）',
        //   fieldName: 'wayPicture2',
        //   placeholder: '上传车牌（车头）...',
        //   offsetRightCols: 1,
        //   initialValue: [],
        //   rules: [{ required: true, message: '请上传车牌（车头）', trigger: 'change' }],
        //   upload: {
        //     actionUrl: '/api/file/oss/upload',
        //     fixedSize: [5, 3],
        //     limit: 1,
        //     isCalcHeight: true,
        //     isFileName:true,
        //   }
        // },
        // {
        //   type: 'UPLOAD_IMG',
        //   label: '行驶证',
        //   fieldName: 'wayPicture3',
        //   placeholder: '上传行驶证...',
        //   selfCols: 1,
        //   initialValue: [],
        //   rules: [{ required: true, message: '请上传行驶证', trigger: 'change' }],
        //   upload: {
        //     actionUrl: '/api/file/oss/upload',
        //     fixedSize: [5, 3],
        //     limit: 1,
        //     isCalcHeight: true,
        //     isFileName:true,
        //   }
        // },
        // {
        //   type: 'UPLOAD_IMG',
        //   label: '故障照片',
        //   fieldName: 'wayPicture4',
        //   placeholder: '上传故障照片...',
        //   selfCols: 1,
        //   initialValue: [],
        //   // rules: [{ required: true, message: '请上传故障照片', trigger: 'change' }],
        //   upload: {
        //     actionUrl: '/api/file/oss/upload',
        //     fixedSize: [5, 3],
        //     limit: 1,
        //     isCalcHeight: true,
        //     isFileName:true,
        //   }
        // },
        // {
        //   type: 'UPLOAD_IMG',
        //   label: '故障照片',
        //   fieldName: 'wayPicture5',
        //   placeholder: '上传故障照片...',
        //   selfCols: 2,
        //   initialValue: [],
        //   // rules: [{ required: true, message: '请上传故障照片', trigger: 'change' }],
        //   upload: {
        //     actionUrl: '/api/file/oss/upload',
        //     fixedSize: [5, 3],
        //     limit: 1,
        //     isCalcHeight: true,
        //     isFileName:true,
        //   }
        // },
      ];
    },
//       createFormList2() {
//         return [
// //           填写救援双边里程、人数、救援目的地、是否偏远地区、救援时间；
//           {
//             type: 'INPUT',
//             label: '人数',
//             fieldName: 'partName',
//             placeholder: '请输入人数...'
//           },
//
//           {
//             type: 'INPUT',
//             label: '救援时间',
//             fieldName: 'faultName',
//             placeholder: '请输入救援时间...'
//           },
//           {
//             type: 'INPUT',
//             label: '救援双边里程',
//             fieldName: 'sysCode4',
//             placeholder: '请输入救援双边里程...'
//           },
//           {
//             type: 'INPUT',
//             label: '救援目的地',
//             fieldName: 'frName',
//             placeholder: '请输入救援目的地...'
//           },
//           {
//             type: 'INPUT',
//             label: '是否偏远地区',
//             fieldName: 'frName',
//             placeholder: '请输入是否偏远地区...'
//           },
//           //   填写燃油补贴、人员补贴、餐补、住宿补贴、节假日补贴、拖车费、救援费；
//           {
//             type: 'DATE',
//             label: '燃油补贴',
//             fieldName: 'selfSdate',
//             placeholder: '请输入燃油补贴...'
//           },
//           {
//             type: 'INPUT',
//             label: '人员补贴',
//             fieldName: 'selfMile',
//             placeholder: '请输入人员补贴...'
//           },
//           {
//             type: 'INPUT',
//             label: '餐补',
//             fieldName: 'faultAppear',
//             placeholder: '请输入餐补...'
//           },
//           {
//             type: 'INPUT',
//             label: '住宿补贴',
//             fieldName: 'faultReason',
//             placeholder: '请输入住宿补贴...'
//           },
//           {
//             type: 'INPUT',
//             label: '节假日补贴',
//             fieldName: 'cmsClaimPgm',
//             placeholder: '请输入节假日补贴...'
//           },
//           {
//             type: 'INPUT',
//             label: '拖车费',
//             fieldName: 'cmsClaimPgm',
//             placeholder: '请输入拖车费...'
//           },
//           {
//             type: 'INPUT',
//             label: '救援费',
//             fieldName: 'cmsClaimPgm',
//             placeholder: '请输入救援费...'
//           },
//
//         ];
//       },
    createdTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          fixed: 'left',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 90,
          render: (props, h) => {
            return (
              <div>
                <el-button size="mini" type="text" onClick={() => this.delVideo(props.row)}>
                  删除
                </el-button>
              </div>
            );
          }
        },
        {
          title: '附件标题',
          dataIndex: 'title',
          showOverflowTooltip: true,
          render: p => {
            return (
              <a style="color:#bb0a30" href={p.row.fileUrl} target="_blank" download={p.row.title}>
                {p.row.title}
              </a>
            );
          }
        },
        {
          title: '上传日期',
          dataIndex: 'createdAt'
        },
      ];
    },
    //维修项目列表
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 100,
          render: props => {
            return (
              <div style="text-align:center">
                <multiuse-button type="text" onClick={() => this.deleteFunweixiu(props.row)} >
                  删除
                </multiuse-button>
              </div>
            );
          }
        },
        { title: '维修项目代码', dataIndex: 'labourCode', sorter: true },
        { title: '维修项目名称', dataIndex: 'labourName', sorter: true },
        { title: '收费区分', dataIndex: 'cmsClaimType', sorter: true },
        { title: '维修工时', dataIndex: 'labourHours', sorter: true, minWidth: 120},
        { title: '索赔工时单价', dataIndex: 'cmsClaimPrice', sorter: true },
        { title: '索赔金额', dataIndex: 'cmsClaimAmount', sorter: true }
      ];
    },
    //备件换上件列表
    creatHeader1() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          fixed: 'left',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 100,
          render: props => {
            return (
              <div style="text-align:center">
                <multiuse-button type="text" onClick={() => this.deleteFunshangjian(props.row)} >
                  删除
                </multiuse-button>
              </div>
            );
          }
        },
        { title: '备件代码', dataIndex: 'partCode', sorter: true },
        { title: '备件名称', dataIndex: 'partName', sorter: true },
        { title: '单位', dataIndex: 'partUnit', sorter: true },
        { title: '数量', dataIndex: 'partCount', sorter: true , minWidth: 120,
          editable: true,
          defaultEditable: true,
          showOverflowTooltip: true,
          editType: 'number',
          editRequired: true,
          rules: [{required: true, message: '请填写数量', trigger: 'blur'}],
          editValidator:(val, row, callback) => {
            if(row.partCount>0){
              row.cmsClaimAmount = parseFloat(eval(row.partCount * row.cmsClaimPrice)).toFixed(2);
              let partAmountsum = 0;
              this.$refs.partTakeOntable.$refs.pageTable.list.map(x => {
                this.sumAmountsum += Number(x.cmsClaimAmount);
                partAmountsum += Number(x.cmsClaimAmount);
              });
              this.feiyongformList.map(x => {
                if ('partAmount' == x.fieldName) {
                  x.initialValue = parseFloat(partAmountsum).toFixed(2);
                }
              });
              this.partAmountsumz=partAmountsum;
              this.sumAmount();
            }else{
              this.$notify.error({ title: '提示信息', message: '数量不能为负数' || '操作失败!' });
              row.partCount = 1
              row.cmsClaimAmount = parseFloat(eval(row.partCount * row.cmsClaimPrice)).toFixed(2);
              let partAmountsum = 0;
              this.$refs.partTakeOntable.$refs.pageTable.list.map(x => {
                this.sumAmountsum += Number(x.cmsClaimAmount);
                partAmountsum += Number(x.cmsClaimAmount);
              });
              this.feiyongformList.map(x => {
                if ('partAmount' == x.fieldName) {
                  x.initialValue = parseFloat(partAmountsum).toFixed(2);
                }
              });
              this.partAmountsumz=partAmountsum;
              this.sumAmount();
            }

          },
        },
        { title: '索赔单价', dataIndex: 'cmsClaimPrice', sorter: true},
        { title: '索赔总价', dataIndex: 'cmsClaimAmount', sorter: true },
        // { title: '是否电池', dataIndex: 'ifEv', sorter: true },
        // { title: '电池编号', dataIndex: 'evNo', sorter: true }
      ];
    },
    //换下件
    columnspartTakeOffFn() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 80,
          render: props => {
            return (
              <div style="text-align:center">
                <multiuse-button type="text" disabled={(this.flag)} onClick={() => this.delsFunXj(props.row)}>
                  删除
                </multiuse-button>
              </div>
            );
          }
        },
        { title: '备件代码', dataIndex: 'beijing', sorter: true,
          render: props => {
            if(getAppId() == 'beijing'){
              return (
                <div style="text-align:center">
                  <multiuse-button type="text" onClick={() => this.chuanvalue(props.row)}>
                    {props.row.partCode}
                  </multiuse-button>
                </div>
              );
            } else{
              return(
                <div>
                  {props.row.partCode}
                </div>
              )
            }
          }},
        { title: '备件名称', dataIndex: 'partName', sorter: true },
        { title: '单位', dataIndex: 'partUnit', sorter: true },
        // { title: '剩余数量', dataIndex: 'lessCount', sorter: true },
        { title: '数量', dataIndex: 'partCount', editable: true,
          showOverflowTooltip: true,
          editType: 'number',
          editRequired: true,
          editValidator:(val, row, callback) => {
            // this.$refs.table1.$refs.pageTable.list.map((x) => {
            //   if (row.partCode == x.partCode) {
            //     this.number = x.partCount
            //   }
            // });
            // if (row.partCount > this.number) {
            //   this.$notify.error({ title: '提示信息', message: '已超过换上件最大数量(' + this.number + ')' || '操作失败!' });
            //   row.partCount = 0
            // }else
            if(row.partCount<0){
              this.$notify.error({ title: '提示信息', message: '换上件最小数量为0' });
              row.partCount = 0
            }
          }

        },
        // { title: '备件回运类型', dataIndex: 'returnType', sorter: true , dictItems:[]},
        // { title: '备件代码', dataIndex: 'partId', hidden: true },
      ];
    },
    //附加项目列表
    columnsappendItem1() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 130,
          render: props => {
            return (
              <div style="text-align:center">
                <multiuse-button type="text" onClick={() => this.editFile(props.row)} >
                  上传附件
                </multiuse-button>
                <el-divider direction="vertical" />
                <multiuse-button type="text" onClick={() => this.deleteFunfujia(props.row)} >
                  删除
                </multiuse-button>
              </div>
            );
          }
        },
        { title: '附加项目代码', dataIndex: 'addCode', sorter: true },
        { title: '附加项目名称', dataIndex: 'addName', sorter: true },
        {
          title: '附加项目费用',
          dataIndex: 'addAmount',
          sorter: true,
          editable: true,
          editType: 'number',
          editValidator: (val, row, callback) => {
            if (row.addAmount < 0) {
              this.$notify.error({ title: '提示信息', message: '附加项目费用最小为0' });
              row.partCount = 0;
            }
          }
        },
        { title: '备注', dataIndex: 'addRemark', sorter: true ,editable: true}
      ];
    },
    //费用信息
    feiyongformList1() {
      return [
        {
          type: 'INPUT',
          label: '合计费用',
          fieldName: 'sumAmount',
          initialValue: 0,
          disabled: true // 只读
        },
        {
          type: 'INPUT',
          label: '工时费用',
          fieldName: 'labourAmount',
          initialValue: 0,
          // readonly: true // 只读
          disabled: true
        },
        {
          type: 'INPUT',
          label: '备件费用',
          fieldName: 'partAmount',
          initialValue: 0,
          //readonly: true // 只读
          disabled: true
        },
        {
          type: 'INPUT',
          label: '附加项目费用',
          fieldName: 'addAmount',
          initialValue: 0,
          // readonly: true // 只读
          disabled: true
        }
      ];
    } /**维修项目删除方法 */,
    deleteFunweixiu(costItem) {
      this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async () => {
          this.$notify({
            title: '提示信息',
            message: '删除成功',
            type: 'success'
          });
          this.$refs.repairItemtable.$refs.pageTable.EXECUTE_DELETE([costItem]);
          this.feiyongformList.map(x => {
            if ('labourAmount' == x.fieldName) {
              x.initialValue = (this.sumweixiufeiyongz - Number(costItem.cmsClaimAmount)).toFixed(2);
              this.sumweixiufeiyongz = (this.sumweixiufeiyongz - Number(costItem.cmsClaimAmount)).toFixed(2)
              this.sumAmount();
            }
          });
        })
    } /**备件换上件删除方法 */,
    deleteFunshangjian(costItem) {
      this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async () => {
          this.$notify({
            title: '提示信息',
            message: '删除成功',
            type: 'success'
          });
          this.$refs.partTakeOntable.$refs.pageTable.EXECUTE_DELETE([costItem]);

          this.feiyongformList.map(x => {
            if ('partAmount' == x.fieldName) {
              x.initialValue = (this.partAmountsumz - Number(costItem.cmsClaimAmount)).toFixed(2);
              this.partAmountsumz=(this.partAmountsumz - Number(costItem.cmsClaimAmount)).toFixed(2);
              this.sumAmount();
            }
          });
        })
    }  /*附加项目删除方法 */,
    deleteFunfujia(costItem) {
      this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async () => {
          this.$notify({
            title: '提示信息',
            message: '删除成功',
            type: 'success'
          });
          this.$refs.appendItemtable.$refs.pageTable.EXECUTE_DELETE([costItem]);

          this.feiyongformList.map(x => {
            if ('addAmount' == x.fieldName) {
              x.initialValue = (this.sumfujiafeiyongz - Number(costItem.addAmount)).toFixed(2);
              this.sumfujiafeiyongz=(this.sumfujiafeiyongz- Number(costItem.addAmount)).toFixed(2);
              this.sumAmount();
            }
          });
        })
    },
    //作废
    async zuofei() {
      const res = await zuofeiFun({ ids: this.rowData.authId, status: '55031006' });
    },
    //提交
    async submit() {
      if( this.powertype) {
        if (this.powertype == 60081001) {
          this.formList1.find(x => x.fieldName == 'wayPicture3').rules[0].required = false;
        }
      }
      this.fileList= [];
      this.saveFlag = 1;
      let submitForm = this.$refs.formPanel1.SUBMIT_FORM();
      if (submitForm !== null) {
        let submitForm2 = this.$refs.formPanel2.SUBMIT_FORM();
        if (submitForm2 !== null) {
          this.$refs.formPanel3.SUBMIT_FORM();

          let arr = [];
          this.$refs.appendItemtable.$refs.pageTable.list.map(x => {

            arr.push(x);
          });
          // let submitFormRescue = this.$refs.formPanelRescue.SUBMIT_FORM();
          let arr1 = [];
          this.$refs.table2.$refs.pageTable.list.map(x => {
            arr1.push(x);
          });

          let arr2 = [];
          this.$refs.partTakeOntable.$refs.pageTable.list.map(x => {
            arr2.push(x);
          });

          let arr3 = [];
          this.$refs.repairItemtable.$refs.pageTable.list.map(x => {
            x.cmsClaimType=1;
            arr3.push(x);
          });

          //维修项目
          this.saveData.labourList = arr3;
          //换上件
          this.saveData.partRList = arr2;
          //换下件
          this.saveData.partList = arr1;
          //附加项目
          this.saveData.addList = arr;

          this.saveData = Object.assign(this.saveData, this.saveData1);

          this.saveData = Object.assign(this.saveData, this.saveData2);

          this.saveData = Object.assign(this.saveData, this.saveData3);
          console.info(12345);
          console.info(this.saveData);
          this.saveData.authStatus = 55031002;

          //追加子表的主键
          this.saveData.faId = this.faId;
          this.saveData.frId = this.frId;
          // this.saveData.outId = this.outId;
          // this.saveData.outNo = this.saveData.outCode;
          // this.saveData.selfNo = this.selfNo;
          this.saveData.partId = this.partId;
          this.saveData.modelCode = this.modelCode;
          this.saveData.modelId = this.modelId;
          //保存前格式化时间类型
          //销售日期
          if(this.saveData.saleDate){
            this.saveData.saleDate = moment(this.saveData.saleDate).format('YYYY-MM-DD HH:mm:ss');
          }
          //保修起始日期
          if(this.saveData.repairBeginDate){
            this.saveData.repairBeginDate = moment(this.saveData.repairBeginDate).format('YYYY-MM-DD HH:mm:ss');
          }
          //保修截止日期
          if(this.saveData.repairEndDate){
            this.saveData.repairEndDate = moment(this.saveData.repairEndDate).format('YYYY-MM-DD HH:mm:ss');
          }
          //开单日期
          if(this.saveData.roCreateDate){
            this.saveData.roCreateDate = moment(this.saveData.roCreateDate).format('YYYY-MM-DD HH:mm:ss');
          }
          // //维修开始时间
          // if(this.saveData.serviceBeginDate){
          //   this.saveData.serviceBeginDate = moment(this.saveData.serviceBeginDate).format('YYYY-MM-DD HH:mm:ss');
          // }
          // //维修结束时间
          // if(this.saveData.serviceEndDate){
          //   this.saveData.serviceEndDate = moment(this.saveData.serviceEndDate).format('YYYY-MM-DD HH:mm:ss');
          // }
          // //自费备件销售日期
          // if(this.saveData.selfSdate){
          //   this.saveData.selfSdate = moment(this.saveData.selfSdate).format('YYYY-MM-DD HH:mm:ss');
          // }
          // //生产日期
          // if(this.saveData.prodDate){
          //   this.saveData.prodDate = moment(this.saveData.prodDate).format('YYYY-MM-DD HH:mm:ss');
          // }
          // if(this.saveData.supName){
          //   // let sup = this.selects.find(x => x.supCode == this.saveData.supName);
          //   this.saveData.supId = this.supId;
          //   this.saveData.supCode = this.supCode;
          // }

          // let p1 ={
          //   title :this.saveData.wayPicture[0].name,
          //   fileUrl : this.saveData.wayPicture[0].url,
          //   type:55041001
          // }
          // let p2 ={
          //   title :this.saveData.wayPicture1[0].name,
          //   fileUrl : this.saveData.wayPicture1[0].url,
          //   type:55041002
          // }
          // let p3 ={
          //   title :this.saveData.wayPicture2[0].name,
          //   fileUrl : this.saveData.wayPicture2[0].url,
          //   type:55041003
          // }
          // let p4 ={
          //   title: this.saveData.wayPicture3[0] == undefined ? null : this.saveData.wayPicture3[0].name,
          //   fileUrl: this.saveData.wayPicture3[0] == undefined ? null : this.saveData.wayPicture3[0].url,
          //   type: 55041004
          // }
          // let p5 ={
          //   title :this.saveData.wayPicture4[0]==undefined? null:this.saveData.wayPicture4[0].name,
          //   fileUrl : this.saveData.wayPicture4[0]==undefined? null:this.saveData.wayPicture4[0].url,
          //   type:55041005
          // }
          // let p6 ={
          //   title :this.saveData.wayPicture5[0]==undefined? null:this.saveData.wayPicture5[0].name,
          //   fileUrl : this.saveData.wayPicture5[0]==undefined? null:this.saveData.wayPicture5[0].url,
          //   type:55041006
          // }
          // this.fileList.push(p1);
          // this.fileList.push(p2);
          // this.fileList.push(p3);
          // this.fileList.push(p4);
          // this.fileList.push(p5);
          // this.fileList.push(p6);
          this.$refs.fileTable.$refs.pageTable.list.map(x => {
            this.fileList.push(x);
          });
          this.saveData.fileList = this.fileList;
          console.log("-1")
          //行驶里程校验
          let flag2 = false;
          if (submitForm.driveMile != null && submitForm.driveMile > 0) {
            flag2 = true;
          } else {
            return this.$notify.warning({title: '提示信息', message: '行驶里程不能为空且为大于0的数！'});
          }
          ;
          //送修人姓名校验
          // let flag3=false;
          // if (submitForm.deliverer != null &&submitForm.deliverer != '') {
          //   flag3=true;
          // }else {
          //   return this.$notify.warning({ title: '提示信息', message: '送修人姓名不能为空！' });
          // };
          //送修人手机号校验
          // let flag4=false;
          // if (submitForm.delivererMobile != null &&submitForm.delivererMobile != '') {
          //   flag4=true;
          // }else {
          //   return this.$notify.warning({ title: '提示信息', message: '送修人手机号不能为空！' });
          // };
          // console.log("0",flag1)
          // console.log("0",flag2)
          // console.log("0",flag3)
          // console.log("0",flag4)
          if (flag2) {
            if (this.saveData !== null && this.feiyongformList.find(x => x.fieldName == 'sumAmount').initialValue != 0) {
              this.loading = true;
              let res = await newSave(this.saveData);

              if (res.resultCode === 200) {
                this.$emit('save');

                return this.$notify.success({title: '提示信息', message: '提交成功'});

              } else {
                console.log("3")
                // if (this.saveFlag === 1) {
                //   this.$notify.error({ title: '提示信息', message: res.errMsg || '提交失败!' });
                // } else {
                //   this.$notify.error({ title: '提示信息', message: res.errMsg || '保存失败!' });
                // }

                // this.closeDialog();
                this.loading = false;
              }
              this.loading = false;
            } else {
              this.$notify.warning({title: '提示信息', message: '请检查维修项目、换上件、附加项目是否存在和必填项！'});
            }
          }
        }
      }
    }
  }
};
</script>

<style lang="less" scoped></style>

